Friday, November 14, 2014

Stripe API Capybara Test Failures

I was getting Stripe::InvalidRequestError: You must supply either a card or a customer id error. To fix this, make sure js is true in your integration test like this:

feature 'Guest Checkout' do
  scenario 'Complete purchase of one product', js: true do
    visit products_show_path
    click_link 'Buy Now'
   
    fill_in "Card Number", with: '4242424242424242'  
    page.select '10', from: "card_month"
    page.select '2029', from: 'card_year'
    click_button 'Buy Now'
   
    expect(page).to have_content('Receipt')
  end
end