Sha256: 800885f1d05d58631f4c820c02d874b486c3d7348046a4200bb3888308bf1626

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

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

module Stripe
  class CouponTest < Test::Unit::TestCase
    should "be listable" do
      coupons = Stripe::Coupon.list
      assert_requested :get, "#{Stripe.api_base}/v1/coupons"
      assert coupons.data.is_a?(Array)
      assert coupons.first.is_a?(Stripe::Coupon)
    end

    should "be retrievable" do
      coupon = Stripe::Coupon.retrieve("25OFF")
      assert_requested :get, "#{Stripe.api_base}/v1/coupons/25OFF"
      assert coupon.is_a?(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.is_a?(Stripe::Coupon)
    end

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

    should "be updateable" do
      coupon = Stripe::Coupon.update("25OFF", metadata: { key: "value" })
      assert_requested :post, "#{Stripe.api_base}/v1/coupons/25OFF"
      assert coupon.is_a?(Stripe::Coupon)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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