stripe-ruby/test/stripe/price_test.rb
remi-stripe 622db9d9e7
Add support for the Price resource and APIs (#917)
* Codegen for openapi f75fd88

* Fix test suite
2020-04-29 12:41:35 -07:00

49 lines
1.3 KiB
Ruby

# 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