mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Move paymentintent to stripe-mock
This commit is contained in:
parent
a097b23a0c
commit
b206552c60
@ -18,7 +18,7 @@ sudo: false
|
|||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
# If changing this number, please also change it in `test/test_helper.rb`.
|
# If changing this number, please also change it in `test/test_helper.rb`.
|
||||||
- STRIPE_MOCK_VERSION=0.16.0
|
- STRIPE_MOCK_VERSION=0.19.0
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
@ -7,9 +7,6 @@ module Stripe
|
|||||||
|
|
||||||
class PaymentIntentTest < Test::Unit::TestCase
|
class PaymentIntentTest < Test::Unit::TestCase
|
||||||
should "be listable" do
|
should "be listable" do
|
||||||
stub_request(:get, "#{Stripe.api_base}/v1/payment_intents")
|
|
||||||
.to_return(body: JSON.generate(object: "list", data: [{ id: "pi_123", object: "payment_intent" }]))
|
|
||||||
|
|
||||||
payment_intents = Stripe::PaymentIntent.list
|
payment_intents = Stripe::PaymentIntent.list
|
||||||
assert_requested :get, "#{Stripe.api_base}/v1/payment_intents"
|
assert_requested :get, "#{Stripe.api_base}/v1/payment_intents"
|
||||||
assert payment_intents.data.is_a?(Array)
|
assert payment_intents.data.is_a?(Array)
|
||||||
@ -17,27 +14,22 @@ module Stripe
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be retrievable" do
|
should "be retrievable" do
|
||||||
stub_request(:get, "#{Stripe.api_base}/v1/payment_intents/pi_123")
|
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
|
||||||
|
|
||||||
payment_intent = Stripe::PaymentIntent.retrieve("pi_123")
|
payment_intent = Stripe::PaymentIntent.retrieve("pi_123")
|
||||||
assert_requested :get, "#{Stripe.api_base}/v1/payment_intents/pi_123"
|
assert_requested :get, "#{Stripe.api_base}/v1/payment_intents/pi_123"
|
||||||
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be creatable" do
|
should "be creatable" do
|
||||||
stub_request(:post, "#{Stripe.api_base}/v1/payment_intents")
|
payment_intent = Stripe::PaymentIntent.create(
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
allowed_source_types: ["card"],
|
||||||
|
amount: 1234,
|
||||||
payment_intent = Stripe::PaymentIntent.create
|
currency: "usd"
|
||||||
|
)
|
||||||
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
|
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
|
||||||
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be saveable" do
|
should "be saveable" do
|
||||||
stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123")
|
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
|
||||||
|
|
||||||
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent", metadata: {})
|
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent", metadata: {})
|
||||||
payment_intent.metadata["key"] = "value"
|
payment_intent.metadata["key"] = "value"
|
||||||
payment_intent.save
|
payment_intent.save
|
||||||
@ -45,9 +37,6 @@ module Stripe
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be updateable" do
|
should "be updateable" do
|
||||||
stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123")
|
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
|
||||||
|
|
||||||
payment_intent = Stripe::PaymentIntent.update("pi_123", metadata: { foo: "bar" })
|
payment_intent = Stripe::PaymentIntent.update("pi_123", metadata: { foo: "bar" })
|
||||||
|
|
||||||
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123"
|
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123"
|
||||||
@ -56,9 +45,6 @@ module Stripe
|
|||||||
|
|
||||||
context "#cancel" do
|
context "#cancel" do
|
||||||
should "cancel a payment_intent" do
|
should "cancel a payment_intent" do
|
||||||
stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123/cancel")
|
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
|
||||||
|
|
||||||
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
||||||
payment_intent = payment_intent.cancel
|
payment_intent = payment_intent.cancel
|
||||||
|
|
||||||
@ -69,9 +55,6 @@ module Stripe
|
|||||||
|
|
||||||
context "#capture" do
|
context "#capture" do
|
||||||
should "capture a payment_intent" do
|
should "capture a payment_intent" do
|
||||||
stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123/capture")
|
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
|
||||||
|
|
||||||
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
||||||
payment_intent = payment_intent.capture
|
payment_intent = payment_intent.capture
|
||||||
|
|
||||||
@ -82,9 +65,6 @@ module Stripe
|
|||||||
|
|
||||||
context "#confirm" do
|
context "#confirm" do
|
||||||
should "confirm a payment_intent" do
|
should "confirm a payment_intent" do
|
||||||
stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123/confirm")
|
|
||||||
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
|
|
||||||
|
|
||||||
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
||||||
payment_intent = payment_intent.confirm
|
payment_intent = payment_intent.confirm
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user