Reputation: 544
I am trying to test an ajax request in rspec, but am not quite sure how to do it at this point It doesnt matter if it is rspec or capybara, I am just trying to get the test to pass, any advice is greatly appreciated
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
Upvotes: 0
Views: 2761
Reputation: 4137
if you want to check behavior after ajax call, like update view. You need use capybara https://github.com/jnicklas/capybara with driver which support javascript, like selenium, webkit
if you just want to test the request, you can use rack-test directly
Upvotes: 1