0
我有一套使用RSpec2和水豚書寫的請求規格。這裏有一個例子:你會如何測試?我想在不同的條件下多次測試一組規格
require 'spec_helper'
describe "Product Display and Interactions" do
it "should hide the price and show SOLD OUT in the product listing when appropriate" do
@product = Factory.create(:sold_out_product)
@product.sale = @sale
@product.save!
visit(sale_path(@sale))
@product.sold_out?.should eq(true)
find("#product_#{@product.id}").should have_content('Sold Out')
end
[...]
end
的問題是,我要出售的幾種不同的視圖模板,每個都有自己的看法諧音產品。有沒有簡單的方法指示RSpec每次運行一系列具有不同條件的規格?我想在這種情況下在@sale記錄上設置一個屬性,然後再次運行所有規格。
或者也許有更好的方法來完全測試這種情況?我是RSpec新手,實際上完全是Rails。