Skip to content

Commit

Permalink
DRYes card and payment intent let groups
Browse files Browse the repository at this point in the history
Fixes typo on capture_amount declaration
  • Loading branch information
filipefurtad0 committed Dec 12, 2023
1 parent b45fc0b commit b259185
Showing 1 changed file with 25 additions and 46 deletions.
71 changes: 25 additions & 46 deletions spec/models/spree/gateway/stripe_sca_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,34 @@
{ order_id: order.number }
}

before { Stripe.api_key = secret }

let(:pm_card) do
Stripe::PaymentMethod.create({
type: 'card',
card: {
number: '4242424242424242',
exp_month: 12,
exp_year: year_valid,
cvc: '314',
},
})
end
let(:payment_intent) do
Stripe::PaymentIntent.create({
amount: 10000, # given in AUD cents

Check warning on line 44 in spec/models/spree/gateway/stripe_sca_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Use underscores(_) as thousands separator and separate every 3 digits with them. Raw Output: spec/models/spree/gateway/stripe_sca_spec.rb:44:44: C: Style/NumericLiterals: Use underscores(_) as thousands separator and separate every 3 digits with them.
currency: 'aud', # AUD to match order currency
payment_method: pm_card,
payment_method_types: ['card'],
capture_method: 'manual',
})
end

describe "#purchase", :vcr, :stripe_version do
before { Stripe.api_key = secret }

let!(:pm_card) do
Stripe::PaymentMethod.create({
type: 'card',
card: {
number: '4242424242424242',
exp_month: 12,
exp_year: year_valid,
cvc: '314',
},
})
end
let!(:payment_intent) do
Stripe::PaymentIntent.create({
amount: 1000, # given in AUD cents
currency: 'aud', # AUD to match order currency
payment_method: pm_card,
payment_method_types: ['card'],
capture_method: 'manual',
})
end

Check warning on line 53 in spec/models/spree/gateway/stripe_sca_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Extra empty line detected at block body beginning. Raw Output: spec/models/spree/gateway/stripe_sca_spec.rb:53:1: C: Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
# Stripe acepts amounts as positive integers representing how much to charge
# in the smallest currency unit
let(:capture_amount) { order.total.to_i * 10 }
let(:capture_amount) { order.total.to_i * 100 }
let(:response) { subject.purchase(capture_amount, credit_card, gateway_options) }

before do
Expand Down Expand Up @@ -81,29 +82,7 @@
end
end

context "#error message", :vcr, :stripe_version do
before { Stripe.api_key = secret }

let!(:pm_card) do
Stripe::PaymentMethod.create({
type: 'card',
card: {
number: '4242424242424242',
exp_month: 12,
exp_year: year_valid,
cvc: '314',
},
})
end
let!(:payment_intent) do
Stripe::PaymentIntent.create({
amount: 1000, # given in AUD cents
currency: 'aud', # AUD to match order currency
payment_method: pm_card,
payment_method_types: ['card'],
capture_method: 'manual',
})
end
describe "#error message", :vcr, :stripe_version do

context "when payment intent state is not in 'requires_capture' state" do
before do
Expand Down

0 comments on commit b259185

Please sign in to comment.