我正在尝试在 rspec 中测试一个 ajax 请求,但目前不太确定如何执行它是 rspec 还是 capybara 无关紧要,我只是想让测试通过,非常感谢任何建议
describe "Cart", js: true, search: true do
let(:product) { create(:product) }
let(:variant) { create(:variant, :product => product, :count_on_hand => 1, :sku=>"YIG01276") }
let(:flash_sale) { create(:flash_sale) }
let(:user) { create(:user) }
before do
flash_sale.variants << variant
flash_sale.save
product.reload
end
it "displays expiring time in cart" do
login_user user
visit spree.product_path(product)
click_button 'Add To Cart'
user.last_incomplete_spree_order.expires_in.should > 0
end
end