Sha256: 9f4f6caca944248e5aacbc47ad390464caad903f111c5012d62b8326fdfec755

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

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

module Stripe
  class PlanTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:plan)

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

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

    should "be creatable" do
      plan = Stripe::Plan.create(
        amount: 5000,
        interval: "month",
        name: "Sapphire elite",
        currency: "usd",
        id: "sapphire-elite"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/plans"
      assert plan.kind_of?(Stripe::Plan)
    end

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

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

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