-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from sasamuku/add_ctx_type
add ctx type
- Loading branch information
Showing
3 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
# rubocop:disable Metrics/BlockLength | ||
RSpec.describe RspecTree do | ||
let(:rspec_file) { File.read("spec/data/sample.rb") } | ||
|
||
describe ".all" do | ||
subject { RspecTree::Tree.new(rspec_file, :all).print } | ||
describe "#print" do | ||
subject { RspecTree::Tree.new(rspec_file, type).print } | ||
|
||
it "prints all (describe, context, it, etc.)" do | ||
expect { subject }.to output(<<~OUTPUT).to_stdout | ||
desc: Sample | ||
desc: First describe | ||
├─────ctx: First context | ||
├───────it: should do something | ||
├───────ctx: First nested context | ||
├─────────it: should do something | ||
├───────it_behaves_like: shared example | ||
desc: Second describe | ||
├─────ctx: Second context | ||
├───────it: should do something else | ||
OUTPUT | ||
context "when called with :all" do | ||
let(:type) { :all } | ||
|
||
it "prints all" do | ||
expect { subject }.to output(<<~OUTPUT).to_stdout | ||
desc: Sample | ||
desc: First describe | ||
├─────ctx: First context | ||
├───────it: should do something | ||
├───────ctx: First nested context | ||
├─────────it: should do something | ||
├───────it_behaves_like: shared example | ||
desc: Second describe | ||
├─────ctx: Second context | ||
├───────it: should do something else | ||
OUTPUT | ||
end | ||
end | ||
|
||
context "when called with :ctx" do | ||
let(:type) { :ctx } | ||
|
||
it "prints only describe and context" do | ||
expect { subject }.to output(<<~OUTPUT).to_stdout | ||
desc: Sample | ||
desc: First describe | ||
├─────ctx: First context | ||
├───────ctx: First nested context | ||
desc: Second describe | ||
├─────ctx: Second context | ||
OUTPUT | ||
end | ||
end | ||
end | ||
end | ||
# rubocop:enable Metrics/BlockLength |