Sha256: e6d45a99412ec473ae0da28e13300e257f89c55ab90f7259030cd9c04689aa2d

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

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

module Stripe
  class CouponTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:coupon)

    should "be listable" do
      coupons = Stripe::Coupon.list
      assert_requested :get, "#{Stripe.api_base}/v1/coupons"
      assert coupons.data.kind_of?(Array)
      assert coupons.first.kind_of?(Stripe::Coupon)
    end

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

    should "be creatable" do
      coupon = Stripe::Coupon.create(
        percent_off: 25,
        duration: 'repeating',
        duration_in_months: 3,
        id: '25OFF'
      )
      assert_requested :post, "#{Stripe.api_base}/v1/coupons"
      assert coupon.kind_of?(Stripe::Coupon)
    end

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

    should "be updateable" do
      coupon = Stripe::Coupon.update(FIXTURE[:id], metadata: { key: 'value' })
      assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
      assert coupon.kind_of?(Stripe::Coupon)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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