Skip to content

Commit

Permalink
Fix test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Apr 29, 2020
1 parent be3141f commit 17bbfdf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -17,7 +17,7 @@ sudo: false
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.88.0
- STRIPE_MOCK_VERSION=0.89.0

cache:
directories:
Expand Down
48 changes: 48 additions & 0 deletions test/stripe/price_test.rb
@@ -0,0 +1,48 @@
# frozen_string_literal: true

require ::File.expand_path("../test_helper", __dir__)

module Stripe
class PriceTest < Test::Unit::TestCase
should "be listable" do
prices = Stripe::Price.list
assert_requested :get, "#{Stripe.api_base}/v1/prices"
assert prices.data.is_a?(Array)
assert prices.data[0].is_a?(Stripe::Price)
end

should "be retrievable" do
price = Stripe::Price.retrieve("price_123")
assert_requested :get, "#{Stripe.api_base}/v1/prices/price_123"
assert price.is_a?(Stripe::Price)
end

should "be creatable" do
price = Stripe::Price.create(
unit_amount: 5000,
currency: "usd",
recurring: {
interval: "month",
},
product_data: {
name: "Product name",
},
)
assert_requested :post, "#{Stripe.api_base}/v1/prices"
assert price.is_a?(Stripe::Price)
end

should "be saveable" do
price = Stripe::Price.retrieve("price_123")
price.metadata["key"] = "value"
price.save
assert_requested :post, "#{Stripe.api_base}/v1/prices/#{price.id}"
end

should "be updateable" do
price = Stripe::Price.update("price_123", metadata: { foo: "bar" })
assert_requested :post, "#{Stripe.api_base}/v1/prices/price_123"
assert price.is_a?(Stripe::Price)
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -16,7 +16,7 @@
require ::File.expand_path("stripe_mock", __dir__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.88.0"
MOCK_MINIMUM_VERSION = "0.89.0"
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down

0 comments on commit 17bbfdf

Please sign in to comment.