Allow passing file+line number while still respecting filter rules
Created by: glennfu
Subject of the issue
I have multiple environments that my specs run against. My code in the rails_helper.rb
is smart enough to adjust filter_run_excluding
or filter_run_including
depending on what it detects. I have a bash script that passes along my run command arguments to multiple rspec commands per environment. This works great for folders, but as soon as I pass a file or a file+line number, everything explodes because my filter rules start getting ignored.
I wish there were some way to run and say "don't ignore filters"
Your environment
- Ruby version: 2.5.5
- rspec-core version: 3.8.2
Steps to reproduce
Add running config.filter_run_excluding special: true
then add special: true
to a spec. Run that spec specifically by line number in the console.
Expected behavior
You should see 0 examples, 0 failures
Actual behavior
I see 1 examples, 1 failures
Workaround
module RSpec
module Core
class FilterManager
def file_scoped_include?(ex_metadata, ids, locations)
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
return yield if MetadataFilter.filter_applies?(:ids, ids, ex_metadata) || MetadataFilter.filter_applies?(:locations, locations, ex_metadata)
end
end
end
end
Idea
I'm really not sure what a solution would look like here. I know that everything is working as intended as described in the Filtering Rules: https://github.com/rspec/rspec-core/blob/master/Filtering.md
How about maybe a flag I can add to the rspec command call that changes this behavior? That would fix my use case, but I don't know if that would be a generic solution for anyone else.