From c518e7e0dd9ae689cf99be5649e1849c8e2f96a6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 28 Sep 2020 19:59:26 +0100 Subject: [PATCH] Extract Stripe credit card form filling --- .../consumer/shopping/checkout_stripe_spec.rb | 12 ++---------- spec/support/request/stripe_helper.rb | 7 +++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/spec/features/consumer/shopping/checkout_stripe_spec.rb b/spec/features/consumer/shopping/checkout_stripe_spec.rb index 09d0444029..e9b5e65230 100644 --- a/spec/features/consumer/shopping/checkout_stripe_spec.rb +++ b/spec/features/consumer/shopping/checkout_stripe_spec.rb @@ -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 diff --git a/spec/support/request/stripe_helper.rb b/spec/support/request/stripe_helper.rb index 82b858a3da..e05ee92bbb 100644 --- a/spec/support/request/stripe_helper.rb +++ b/spec/support/request/stripe_helper.rb @@ -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" }