Sha256: d5afa7a7e350f826823bbaef51c0874f47d68888293ce1763e1cfa28c0827341

Contents?: true

Size: 1.48 KB

Versions: 20

Compression:

Stored size: 1.48 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

module Stripe
  class SKUTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:sku)

    should "be listable" do
      skus = Stripe::SKU.list
      assert_requested :get, "#{Stripe.api_base}/v1/skus"
      assert skus.data.kind_of?(Array)
      assert skus.data[0].kind_of?(Stripe::SKU)
    end

    should "be retrievable" do
      sku = Stripe::SKU.retrieve(FIXTURE[:id])
      assert_requested :get, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
      assert sku.kind_of?(Stripe::SKU)
    end

    should "be creatable" do
      _ = Stripe::SKU.create(
        currency: "USD",
        inventory: { type: "finite", quantity: 500 },
        price: 100,
        product: API_FIXTURES.fetch(:product)[:id]
      )
      assert_requested :post, "#{Stripe.api_base}/v1/skus"
    end

    should "be saveable" do
      sku = Stripe::SKU.retrieve(FIXTURE[:id])
      sku.metadata['key'] = 'value'
      sku.save
      assert_requested :post, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
    end

    should "be updateable" do
      sku = Stripe::SKU.update(FIXTURE[:id], metadata: {foo: 'bar'})
      assert_requested :post, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
      assert sku.kind_of?(Stripe::SKU)
    end

    should "be deletable" do
      sku = Stripe::SKU.retrieve(FIXTURE[:id])
      sku = sku.delete
      assert_requested :delete, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
      assert sku.kind_of?(Stripe::SKU)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
stripe-3.0.3 test/stripe/sku_test.rb
stripe-3.0.1 test/stripe/sku_test.rb
stripe-3.0.0 test/stripe/sku_test.rb
stripe-2.12.0 test/stripe/sku_test.rb
stripe-2.11.0 test/stripe/sku_test.rb
stripe-2.10.0 test/stripe/sku_test.rb
stripe-2.9.0 test/stripe/sku_test.rb
stripe-2.8.0 test/stripe/sku_test.rb
stripe-2.7.0 test/stripe/sku_test.rb
stripe-2.6.0 test/stripe/sku_test.rb
stripe-2.5.0 test/stripe/sku_test.rb
stripe-2.4.0 test/stripe/sku_test.rb
stripe-2.3.0 test/stripe/sku_test.rb
stripe-2.2.1 test/stripe/sku_test.rb
stripe-2.2.0 test/stripe/sku_test.rb
stripe-2.1.0 test/stripe/sku_test.rb
stripe-2.0.3 test/stripe/sku_test.rb
stripe-2.0.2 test/stripe/sku_test.rb
stripe-2.0.1 test/stripe/sku_test.rb
stripe-2.0.0 test/stripe/sku_test.rb