rspec一遍又一遍地重复测试

时间:2014-03-19 01:11:02

标签: rspec

如何针对rspec中的不同条件重复特定测试?

现在我做

it 'should be able to go through the checkout flow with shipping_address/shipping_fees' do
    @app.account_ids.each_with_index do |account_id, country|
             TEST BODY
        end
end

但这似乎不是一种优雅的方式。还有更好的方法吗?

对于每个account_id来说,相当于一遍又一遍地重复TEST BODY?

1 个答案:

答案 0 :(得分:0)

您可以按如下方式重复it来电:

@app.account_ids.each_with_index do |account_id, country|
   it "should be able to go through the checkout flow with shipping_address/shipping_fees" do
      TEST BODY
   end
end

这将允许TEST BODY的每个实例独立失败。