给定示例 sinatra 应用程序
post '/1' do
sleep(1) until @2
0
end
post '/2' do
@2 = true
0
end
和示例 RSpec 测试
describe 'test' do
it 'does /1' do
post '/1'
expect(last_response.body) to eq?(0)
end
it 'does /2'
post '/2'
expect(last_response.body) to eq?(0)
end
end
第一个测试 ( it does /1
) 将挂起,等待 /2 被调用。
是否可以告诉 RSpec 在开始测试 #2 之前不要等待测试 #1 的结果完成?AKA,在 RSpec 中可以进行异步测试吗?