跳过 RSpec 中的多个示例?
Skip multiple examples in RSpec?
有谁知道一种方法可以跳过组内的多个示例,而不会在它们之间重复跳过语句?
例如,给出这个测试:
describe 'some feature' do
it 'should do something' do
...
end
it 'should do something else too' do
...
end
end
a skip
如果放在第一个示例之前不起作用,如下所示:
describe 'some feature' do
skip 'I would like to skip both with one statement'
it 'should do something' do
...
end
it 'should do something else too' do
...
end
end
一个理想的解决方案是允许我跳过示例结构的任何级别(describe
/feature
、context
和 scenario
/it
) 并会跳过该层级的所有子级。
换句话说,可以让我做:
describe 'some feature' do
it 'should do something' do
...
end
it 'should do something else too' do
skip 'just one of these for now'
...
end
end
和
describe 'some feature' do
skip 'everything within this describe block'
it 'should do something' do
...
end
it 'should do something else too' do
...
end
end
以及
describe 'some feature' do
context 'such and such' do
skip 'just this context'
it 'should do something' do
...
end
it 'should do something else too' do
...
end
it 'but do not skip this one' do
...
end
end
如 documentation 中所述,您可以使用元数据跳过上下文。
describe 'some feature', :skip do
it 'should do something' do
# This example is skipped
end
it 'should do something else too' do
# This example is skipped as well
end
end
有谁知道一种方法可以跳过组内的多个示例,而不会在它们之间重复跳过语句?
例如,给出这个测试:
describe 'some feature' do
it 'should do something' do
...
end
it 'should do something else too' do
...
end
end
a skip
如果放在第一个示例之前不起作用,如下所示:
describe 'some feature' do
skip 'I would like to skip both with one statement'
it 'should do something' do
...
end
it 'should do something else too' do
...
end
end
一个理想的解决方案是允许我跳过示例结构的任何级别(describe
/feature
、context
和 scenario
/it
) 并会跳过该层级的所有子级。
换句话说,可以让我做:
describe 'some feature' do
it 'should do something' do
...
end
it 'should do something else too' do
skip 'just one of these for now'
...
end
end
和
describe 'some feature' do
skip 'everything within this describe block'
it 'should do something' do
...
end
it 'should do something else too' do
...
end
end
以及
describe 'some feature' do
context 'such and such' do
skip 'just this context'
it 'should do something' do
...
end
it 'should do something else too' do
...
end
it 'but do not skip this one' do
...
end
end
如 documentation 中所述,您可以使用元数据跳过上下文。
describe 'some feature', :skip do
it 'should do something' do
# This example is skipped
end
it 'should do something else too' do
# This example is skipped as well
end
end