Sha256: 53bb04094c30f9ae485165a3dfc4e17a72766055b57ea1db1fafbdf99ee0c2b0

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

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

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

    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
end

Version data entries

10 entries across 10 versions & 1 rubygems

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