Skip to content

Commit

Permalink
Merge pull request #1963 from bentheax/issue-1961-line-filter-regression
Browse files Browse the repository at this point in the history
Use :rerun_file_path when checking location filters
  • Loading branch information
JonRowe committed May 18, 2015
2 parents 98ade33 + b8319b0 commit 1e0dc13
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rspec/core/filter_manager.rb
Expand Up @@ -99,8 +99,10 @@ def prune_conditionally_filtered_examples(examples)
# defined in the same file as the location filters. Excluded specs in
# other files should still be excluded.
def file_scoped_include?(ex_metadata, ids, locations)
no_location_filters = locations[ex_metadata[:absolute_file_path]].empty?
no_id_filters = ids[ex_metadata[:rerun_file_path]].empty?
no_location_filters = locations[
File.expand_path(ex_metadata[:rerun_file_path])
].empty?

return yield if no_location_filters && no_id_filters

Expand Down
22 changes: 22 additions & 0 deletions spec/rspec/core/filter_manager_spec.rb
Expand Up @@ -159,6 +159,28 @@ def example_with(*args)
included_via_tag, excluded_via_tag
]).map(&:description)).to eq([included_via_loc_or_id, included_via_tag].map(&:description))
end

it "skips examples in external files when included from a #{type} filtered file" do
group = RSpec.describe("group")

included_via_loc_or_id = group.example("inc via #{type}"); line = __LINE__

# instantiate shared example in external file
instance_eval <<-EOS, "a_shared_example.rb", 1
RSpec.shared_examples_for("a shared example") do
example("inside of a shared example")
end
EOS

included_via_behaves_like = group.it_behaves_like("a shared example")
test_inside_a_shared_example = included_via_behaves_like.examples.first

add_filter(:line_number => line, :scoped_id => "1:1")

expect(prune([
included_via_loc_or_id, test_inside_a_shared_example
]).map(&:description)).to eq([included_via_loc_or_id].map(&:description))
end
end

describe "location filtering" do
Expand Down

0 comments on commit 1e0dc13

Please sign in to comment.