Sha256: 8f1cfb0f9d1996d15281c03318f8bdb8e4af890f257d9cbbadb2f79f45b52e9d

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 ProductTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:product)

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

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

    should "be creatable" do
      _ = Stripe::Product.create(
        name: "My Product"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/products"
    end

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

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

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