Sha256: 9fba552d7f84478e75e1d1a43087cae1c067f297e43f49b75fb7599741163014

Contents?: true

Size: 1.79 KB

Versions: 45

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

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

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

    should "be retrievable" do
      product = Stripe::Product.retrieve("prod_123")
      assert_requested :get, "#{Stripe.api_base}/v1/products/prod_123"
      assert product.is_a?(Stripe::Product)
    end

    should "be creatable" do
      product = Stripe::Product.create(
        name: "My Product",
        type: "good"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/products"
      assert product.is_a?(Stripe::Product)
    end

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

    should "be updateable" do
      product = Stripe::Product.update("prod_123", metadata: { foo: "bar" })
      assert_requested :post, "#{Stripe.api_base}/v1/products/prod_123"
      assert product.is_a?(Stripe::Product)
    end

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

    context ".delete" do
      should "be deletable" do
        product = Stripe::Product.delete("prod_123")
        assert_requested :delete, "#{Stripe.api_base}/v1/products/prod_123"
        assert product.is_a?(Stripe::Product)
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
stripe-5.25.0 test/stripe/product_test.rb
stripe-5.24.0 test/stripe/product_test.rb
stripe-5.23.1 test/stripe/product_test.rb
stripe-5.23.0 test/stripe/product_test.rb
stripe-5.22.0 test/stripe/product_test.rb
stripe-5.21.0 test/stripe/product_test.rb
stripe-5.20.0 test/stripe/product_test.rb
stripe-5.19.0 test/stripe/product_test.rb
stripe-5.18.0 test/stripe/product_test.rb
stripe-5.17.0 test/stripe/product_test.rb
stripe-5.16.0 test/stripe/product_test.rb
stripe-5.15.0 test/stripe/product_test.rb
stripe-5.14.0 test/stripe/product_test.rb
stripe-5.13.0 test/stripe/product_test.rb
stripe-5.12.1 test/stripe/product_test.rb
stripe-5.12.0 test/stripe/product_test.rb
stripe-5.11.0 test/stripe/product_test.rb
stripe-5.10.0 test/stripe/product_test.rb
stripe-5.9.0 test/stripe/product_test.rb
stripe-5.8.0 test/stripe/product_test.rb