I\'ve hit the wall trying to write an integration test for Stripe\'s checkout.js [ https://checkout.stripe.com/checkout.js ] for my Rails 3.2 app.
Stripe checkout wo
I tried James's answer and modified for my current environment. Here is my code (system spec with Chrome headless):
require 'rails_helper'
describe 'Orders', type: :system do
before do
# Temporarily change default_max_wait_time to wait for Stripe response
@old_wait_time = Capybara.default_max_wait_time
Capybara.default_max_wait_time = 10
end
after do
Capybara.default_max_wait_time = @old_wait_time
end
scenario 'Payment via Stripe', js: true do
visit payment_path
click_button 'Pay with Card'
# Use VCR to avoid actual data creation
VCR.use_cassette 'orders/payment_via_stripe' do
expect(page).to have_css('iframe[name="stripe_checkout_app"]')
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
Capybara.within_frame stripe_iframe do
# Set values by placeholders
fill_in 'Card number', with: '4242424242424242'
fill_in 'MM / YY', with: '08/44'
fill_in 'CVC', with: '999'
# You might need to fill more fields...
click_button 'Pay $9.99'
end
# Confirm payment completed
expect(page).to have_content 'Payment completed.'
end
end
end
I am using:
My app is built according to https://stripe.com/docs/checkout/rails .