Sha256: e5904447a342b789608658a024aba4a45d41c845424fc505aa0e325b3a6a9b8c

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

# 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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
stripe-5.31.0 test/stripe/price_test.rb
stripe-5.30.0 test/stripe/price_test.rb
stripe-5.29.1 test/stripe/price_test.rb
stripe-5.29.0 test/stripe/price_test.rb
stripe-5.28.0 test/stripe/price_test.rb
stripe-5.27.0 test/stripe/price_test.rb
stripe-5.26.0 test/stripe/price_test.rb
stripe-5.25.0 test/stripe/price_test.rb
stripe-5.24.0 test/stripe/price_test.rb
stripe-5.23.1 test/stripe/price_test.rb
stripe-5.23.0 test/stripe/price_test.rb
stripe-5.22.0 test/stripe/price_test.rb
stripe-5.21.0 test/stripe/price_test.rb