我尝试为示例做复杂的过滤器。我有这个代码:
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
当我运行“rspec,我有一些输出
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
但是如果我只想运行一个示例并将这一行添加到 Rspec.configure
config.filter_run :first => true
我想得到
foo
first
case 1 foooobar
refresh doc
但是当我有一些意想不到的输出之后
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
有人知道如何使它正常工作吗?谢谢。