Skip to content

Commit

Permalink
Fix card input in feature specs
Browse files Browse the repository at this point in the history
  • Loading branch information
filippoliverani authored and kennyadsl committed Jan 22, 2021
1 parent f35a20d commit e8cfd15
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/solidus_stripe/testing_support/card_input_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@ def fill_in_card(card = {})

if preferred_v3_elements || preferred_v3_intents
within_frame find('#card_number iframe') do
card[:number].split('').each { |n| find_field('cardnumber').native.send_keys(n) }
fill_in_number("cardnumber", card)
end
within_frame(find '#card_cvc iframe') { fill_in 'cvc', with: card[:code] }
within_frame(find '#card_expiry iframe') do
"#{card[:exp_month]}#{card[:exp_year].last(2)}".split('').each { |n| find_field('exp-date').native.send_keys(n) }
fill_in_expiration("exp-date", card)
end
else
fill_in "Card Number", with: card[:number]
fill_in_number("Card Number", card)
fill_in "Card Code", with: card[:code]
fill_in "Expiration", with: "#{card[:exp_month]} / #{card[:exp_year]}"
fill_in_expiration("Expiration", card)
end
end

private

def fill_in_number(field_name, card)
card[:number].split('').each { |n| find_field(field_name).native.send_keys(n) }
end

def fill_in_expiration(field_name, card)
"#{card[:exp_month]}#{card[:exp_year].last(2)}".split('').each { |n| find_field(field_name).native.send_keys(n) }
end
end

0 comments on commit e8cfd15

Please sign in to comment.