0
是否可以定義橫跨多個測試(在RSpec中)的水豚範圍?水豚跨範圍跨越多個測試
例如,我想關閉此:
it 'has two things' do
within('.some-div') do
expect(page).to have_text('foo')
expect(page).to have_text('bar')
end
end
成這樣:
context 'with two things' do
before :each do
within('.some-div') # pseudo-code - this doesn't work
end
it 'has foo' do
expect(page).to have_text('foo')
end
it 'has bar' do
expect(page).to have_text('bar')
end
end
我試圖使用around
塊這樣的:
around :each do |example|
within('.some-div') do
example.run
end
end
雖然這解析並運行,它實際上並沒有將within
作用域應用於示例。