Extract Stripe credit card form filling

This commit is contained in:
Matt-Yorkley
2020-09-28 19:59:26 +01:00
parent 2babfa9a7b
commit c518e7e0dd
2 changed files with 9 additions and 10 deletions

View File

@@ -109,11 +109,7 @@ feature "Check out with Stripe", js: true do
save_default_addresses: false
)
expect(page).to have_css("input[name='cardnumber']")
fill_in 'Card number', with: '4242424242424242'
fill_in 'MM / YY', with: "01/#{DateTime.now.year + 1}"
fill_in 'CVC', with: '123'
fill_out_card_details
place_order
@@ -145,11 +141,7 @@ feature "Check out with Stripe", js: true do
save_default_addresses: false
)
expect(page).to have_css("input[name='cardnumber']")
fill_in 'Card number', with: '4242424242424242'
fill_in 'MM / YY', with: "01/#{DateTime.now.year + 1}"
fill_in 'CVC', with: '123'
fill_out_card_details
place_order

View File

@@ -1,6 +1,13 @@
# frozen_string_literal: true
module StripeHelper
def fill_out_card_details
expect(page).to have_css("input[name='cardnumber']")
fill_in 'Card number', with: '4242424242424242'
fill_in 'MM / YY', with: "01/#{DateTime.now.year + 1}"
fill_in 'CVC', with: '123'
end
def setup_stripe
allow(Stripe).to receive(:api_key) { "sk_test_12345" }
allow(Stripe).to receive(:publishable_key) { "pk_test_12345" }