Sha256: 652b97581982370b02811c125ae3203e708bcd6afae37132e28904c37915b3e4

Contents?: true

Size: 1.71 KB

Versions: 20

Compression:

Stored size: 1.71 KB

Contents

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

module Stripe
  class SubscriptionItemTest < Test::Unit::TestCase
    should "be listable" do
      items = Stripe::SubscriptionItem.list(
        subscription: "sub_123"
      )
      assert_requested :get, "#{Stripe.api_base}/v1/subscription_items",
                       query: { subscription: "sub_123" }
      assert items.data.is_a?(Array)
      assert items.data[0].is_a?(Stripe::SubscriptionItem)
    end

    should "be retrievable" do
      item = Stripe::SubscriptionItem.retrieve("si_123")
      assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/si_123"
      assert item.is_a?(Stripe::SubscriptionItem)
    end

    should "be creatable" do
      item = Stripe::SubscriptionItem.create(
        item: "silver",
        plan: "sapphire-elite",
        quantity: 3,
        subscription: "sub_123"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/subscription_items"
      assert item.is_a?(Stripe::SubscriptionItem)
    end

    should "be saveable" do
      item = Stripe::SubscriptionItem.retrieve("si_123")
      item.quantity = 4
      item.save
      assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
    end

    should "be updateable" do
      item = Stripe::SubscriptionItem.update("si_123", metadata: { foo: "bar" })
      assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_123"
      assert item.is_a?(Stripe::SubscriptionItem)
    end

    should "be deletable" do
      item = Stripe::SubscriptionItem.retrieve("si_123")
      item = item.delete
      assert_requested :delete, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
      assert item.is_a?(Stripe::SubscriptionItem)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
stripe-3.14.0 test/stripe/subscription_item_test.rb
stripe-3.13.1 test/stripe/subscription_item_test.rb
stripe-3.13.0 test/stripe/subscription_item_test.rb
stripe-3.12.1 test/stripe/subscription_item_test.rb
stripe-3.12.0 test/stripe/subscription_item_test.rb
stripe-3.11.0 test/stripe/subscription_item_test.rb
stripe-3.10.0 test/stripe/subscription_item_test.rb
stripe-3.9.2 test/stripe/subscription_item_test.rb
stripe-3.9.1 test/stripe/subscription_item_test.rb
stripe-3.9.0 test/stripe/subscription_item_test.rb
stripe-3.8.2 test/stripe/subscription_item_test.rb
stripe-3.8.1 test/stripe/subscription_item_test.rb
stripe-3.8.0 test/stripe/subscription_item_test.rb
stripe-3.7.0 test/stripe/subscription_item_test.rb
stripe-3.6.0 test/stripe/subscription_item_test.rb
stripe-3.5.3 test/stripe/subscription_item_test.rb
stripe-3.5.2 test/stripe/subscription_item_test.rb
stripe-3.5.1 test/stripe/subscription_item_test.rb
stripe-3.5.0 test/stripe/subscription_item_test.rb
stripe-3.4.1 test/stripe/subscription_item_test.rb