Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/guard/rspec_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def self.extract_spec_location(metadata)
location = metadata[:location]

until spec_path?(location)
metadata = metadata[:example_group]
metadata = metadata[:parent_example_group] || metadata[:example_group]

unless metadata
STDERR.puts "no spec file found for #{root_metadata[:location]}"
STDERR.puts "no spec file location in #{root_metadata.inspect}"
return root_metadata[:location]
end

Expand Down
32 changes: 31 additions & 1 deletion spec/lib/guard/rspec_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,43 @@ def expected_output(spec_filename)
}

expect(STDERR).to receive(:puts).
with("no spec file found for #{metadata[:location]}") {}
with("no spec file location in #{metadata.inspect}")

expect(described_class.extract_spec_location(metadata)).
to eq metadata[:location]
end
end

context "when a shared examples are nested" do
it "should return location of the root spec" do
metadata = {
location: "./spec/support/breadcrumbs.rb:75",
example_group: {
example_group: {
location: "./spec/requests/breadcrumbs_spec.rb:218"
}
}
}

expect(described_class.extract_spec_location(metadata)).
to eq "./spec/requests/breadcrumbs_spec.rb"
end
end

context "when RSpec 3.0 metadata is present" do
it "should return location of the root spec" do
metadata = {
location: "./spec/support/breadcrumbs.rb:75",
parent_example_group: {
location: "./spec/requests/breadcrumbs_spec.rb:218"
}
}

expect(described_class.extract_spec_location(metadata)).
to eq "./spec/requests/breadcrumbs_spec.rb"
end
end

context "with only success" do
it "notifies success" do
formatter.dump_summary(*summary_with_no_failures)
Expand Down