Sha256: c1e200d355a2ce059f0636ed7bffebd3e7283f53af68a9e38c02dcd00f052a78

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 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

    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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stripe-3.23.0 test/stripe/sku_test.rb
stripe-3.22.0 test/stripe/sku_test.rb
stripe-3.21.0 test/stripe/sku_test.rb
stripe-3.20.0 test/stripe/sku_test.rb
stripe-3.19.0 test/stripe/sku_test.rb
stripe-3.18.0 test/stripe/sku_test.rb
stripe-3.17.2 test/stripe/sku_test.rb
stripe-3.17.1 test/stripe/sku_test.rb
stripe-3.17.0 test/stripe/sku_test.rb
stripe-3.15.0 test/stripe/sku_test.rb