Sha256: 238a70c65b5513a44cf174347c3357687e0d57b624900a7dc9ba850ad738692f

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

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

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

    should "be retrievable" do
      sku = Stripe::SKU.retrieve("sku_123")
      assert_requested :get, "#{Stripe.api_base}/v1/skus/sku_123"
      assert sku.is_a?(Stripe::SKU)
    end

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

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

    should "be updateable" do
      sku = Stripe::SKU.update("sku_123", metadata: { foo: "bar" })
      assert_requested :post, "#{Stripe.api_base}/v1/skus/sku_123"
      assert sku.is_a?(Stripe::SKU)
    end

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

    context ".delete" do
      should "be deletable" do
        sku = Stripe::SKU.delete("sku_123")
        assert_requested :delete, "#{Stripe.api_base}/v1/skus/sku_123"
        assert sku.is_a?(Stripe::SKU)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stripe-4.18.0 test/stripe/sku_test.rb
stripe-4.17.0 test/stripe/sku_test.rb
stripe-4.16.0 test/stripe/sku_test.rb
stripe-4.15.0 test/stripe/sku_test.rb
stripe-4.14.0 test/stripe/sku_test.rb
stripe-4.13.0 test/stripe/sku_test.rb
stripe-4.12.0 test/stripe/sku_test.rb