How I can make the complex filter for examples-Collection of common programming errors
I try to do complex filter for examples. I have this code:
require 'rspec'
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :foo => true
end
describe 'Filtering' do
tested_text = 'foooobar'
[:foo, :bar].each do |location|
[:first, :second].each do |current|
describe 'aaa ' + location.to_s, location => true do
before :all, location => true do
puts location
end
describe 'bbbb '+ current.to_s, current => true do
before :all, current => true do
puts current
end
it 'case 1 ' do
puts 'case 1 ' + tested_text.to_s
end
end
end
end
end
after :each do
puts 'refresh doc'
end
end
When I run “rspec, I have some output
foo
first
case 1 foooobar
refresh doc
foo
second
case 1 foooobar
refresh doc
2 examples, 0 failures, 2 passed
Finished in 0.006087512 seconds
But If I want run only one example and add this line to Rspec.configure
config.filter_run :first => true
And I want to get
foo
first
case 1 foooobar
refresh doc
But after when I have some unexpected output
foo
first
case 1 foooobar
refresh doc
foo
second
case 1 foooobar
refresh doc
bar
first
case 1 foooobar
refresh doc
3 examples, 0 failures, 3 passed
Finished in 0.011501239 seconds
Does enybody know how to make it work properly? Thanks.