mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-06 00:02:18 -04:00
Redefining the constant like this produces a warning: ``` $ bundle exec rake /Users/brandur/stripe/stripe-ruby/test/stripe/ephemeral_key_test.rb:75: warning: already initialized constant Stripe::EphemeralKeyTest::FIXTURE /Users/brandur/stripe/stripe-ruby/test/stripe/ephemeral_key_test.rb:6: warning: previous definition of FIXTURE was here Loaded suite /Users/brandur/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/rake_test_loader Started ... ``` They also don't appear to be used, so it should be fine just to strip them out of the test suite.
85 lines
2.2 KiB
Ruby
85 lines
2.2 KiB
Ruby
require File.expand_path('../../test_helper', __FILE__)
|
|
|
|
module Stripe
|
|
class EphemeralKeyTest < Test::Unit::TestCase
|
|
context "#create" do
|
|
should "succeed" do
|
|
key = Stripe::EphemeralKey.create(
|
|
{customer:"cus_123"},
|
|
{stripe_version:"2017-05-25"}
|
|
)
|
|
|
|
assert_requested(
|
|
:post,
|
|
"#{Stripe.api_base}/v1/ephemeral_keys",
|
|
headers: {'Stripe-Version' => '2017-05-25'}
|
|
)
|
|
|
|
assert key.kind_of?(Stripe::EphemeralKey)
|
|
end
|
|
|
|
context "#no global version" do
|
|
should "use the correct api version" do
|
|
key = Stripe::EphemeralKey.create(
|
|
{customer: "cus_123"},
|
|
{stripe_version: "2017-06-05"}
|
|
)
|
|
|
|
assert_requested(
|
|
:post,
|
|
"#{Stripe.api_base}/v1/ephemeral_keys",
|
|
headers: {'Stripe-Version' => '2017-06-05'}
|
|
)
|
|
|
|
assert key.kind_of?(Stripe::EphemeralKey)
|
|
end
|
|
|
|
should "error without an explicit api version" do
|
|
e = assert_raises(ArgumentError) do
|
|
Stripe::EphemeralKey.create(customer: "cus_123")
|
|
end
|
|
assert_match("stripe_version must be specified", e.message)
|
|
end
|
|
end
|
|
|
|
context "#with global version" do
|
|
setup do
|
|
Stripe.api_version = "2017-05-25"
|
|
end
|
|
|
|
teardown do
|
|
Stripe.api_version = nil
|
|
end
|
|
|
|
should "use the correct api version" do
|
|
key = Stripe::EphemeralKey.create(
|
|
{customer: "cus_123"},
|
|
{stripe_version: "2017-05-25"}
|
|
)
|
|
|
|
assert key.kind_of?(Stripe::EphemeralKey)
|
|
end
|
|
|
|
should "error without an explicit api version" do
|
|
e = assert_raises(ArgumentError) do
|
|
Stripe::EphemeralKey.create(customer: "cus_123")
|
|
end
|
|
assert_match("stripe_version must be specified", e.message)
|
|
end
|
|
end
|
|
end
|
|
|
|
context "#delete" do
|
|
should "succeed" do
|
|
key = Stripe::EphemeralKey.create(
|
|
{customer: 'cus_123'},
|
|
{stripe_version: '2017-05-25'}
|
|
)
|
|
|
|
key.delete
|
|
assert_requested :delete, "#{Stripe.api_base}/v1/ephemeral_keys/#{key.id}"
|
|
end
|
|
end
|
|
end
|
|
end
|