I'm using rspec + vcr and I have the weirdest freaking error I have ever seen.
When I make this change:
My test goes from:
PaymentProcessingService
.capture_charge
stripe
should work if authorization is missing
Finished in 9.32 seconds (files took 16.33 seconds to load)
1 example, 0 failures
PaymentProcessingService
.capture_charge
stripe
should work if authorization expired/has been refunded (FAILED - 1)
Failures:
1) PaymentProcessingService.capture_charge stripe should work if authorization expired/has been refunded
Failure/Error:
raise Sneakers::PaymentFailedError.new(
message: error[:code] || error[:message],
amount_cents: payment_breakdown[:charge_amount_cents],
transaction_id: error[:charge],
fraud: error[:code] == 'card_declined' && ['fraudulent', 'lost_card', 'stolen_card'].include?(error[:decline_code]),
decline_code: error[:decline_code]
)
Sneakers::PaymentFailedError:
You cannot use a Stripe token more than once: tok_CWdiwIchZfRjEK.
# ./app/services/payment_processing_service.rb:267:in `rescue in charge_stripe'
# ./app/services/payment_processing_service.rb:209:in `charge_stripe'
# ./app/services/payment_processing_service.rb:79:in `charge_card_internal'
# ./app/services/payment_processing_service.rb:418:in `capture_charge_stripe'
# ./app/services/payment_processing_service.rb:385:in `capture_charge_internal'
# ./app/services/payment_processing_service.rb:35:in `capture_charge'
# ./spec/services/payment_processing_service_spec.rb:229:in `block (4 levels) in <top (required)>'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/vcr-4.0.0/lib/vcr/util/variable_args_block_caller.rb:9:in `call_block'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/vcr-4.0.0/lib/vcr.rb:188:in `use_cassette'
# ./spec/rails_helper.rb:120:in `block (2 levels) in <top (required)>'
# ./spec/rails_helper.rb:106:in `block (2 levels) in <top (required)>'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:115:in `block in run'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `loop'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `run'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/rspec-retry-0.5.6/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:33:in `block (2 levels) in setup'
# ------------------
# --- Caused by: ---
# Faraday::ClientError:
# the server responded with status 400
# /Users/kurtis.rainboltgreene/.rvm/gems/ruby-2.4.3@sneakers/gems/faraday-0.13.1/lib/faraday/response/raise_error.rb:13:in `on_complete'
Finished in 10.22 seconds (files took 19.85 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/services/payment_processing_service_spec.rb:222 # PaymentProcessingService.capture_charge stripe should work if authorization expired/has been refunded
Now, I have no idea why this happens, but I have all the time in the world to figure it out.
Hi all!
I'm using rspec + vcr and I have the weirdest freaking error I have ever seen.
When I make this change:
My test goes from:
Now, I have no idea why this happens, but I have all the time in the world to figure it out.