Sha256: 8297515a1cff0325f12f335fbd88724906722610ce3cf5b0a8bc29e0fca19325

Contents?: true

Size: 1.74 KB

Versions: 29

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

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

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

    should "be retrievable" do
      charge = Stripe::Charge.retrieve("ch_123")
      assert_requested :get, "#{Stripe.api_base}/v1/charges/ch_123"
      assert charge.is_a?(Stripe::Charge)
    end

    should "be creatable" do
      charge = Stripe::Charge.create(
        amount: 100,
        currency: "USD",
        source: "src_123"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/charges"
      assert charge.is_a?(Stripe::Charge)
    end

    should "be saveable" do
      charge = Stripe::Charge.retrieve("ch_123")
      charge.metadata["key"] = "value"
      charge.save
      assert_requested :post, "#{Stripe.api_base}/v1/charges/#{charge.id}"
    end

    should "be updateable" do
      charge = Stripe::Charge.update("ch_123", metadata: { foo: "bar" })
      assert_requested :post, "#{Stripe.api_base}/v1/charges/ch_123"
      assert charge.is_a?(Stripe::Charge)
    end

    context "#mark_as_fraudulent" do
      should "charges should be able to be marked as fraudulent" do
        charge = Stripe::Charge.retrieve("ch_123")
        charge = charge.mark_as_fraudulent
        assert charge.is_a?(Stripe::Charge)
      end
    end

    context "#mark_as_safe" do
      should "charges should be able to be marked as safe" do
        charge = Stripe::Charge.retrieve("ch_123")
        charge = charge.mark_as_safe
        assert charge.is_a?(Stripe::Charge)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
stripe-4.11.0 test/stripe/charge_test.rb
stripe-4.10.0 test/stripe/charge_test.rb
stripe-4.9.1 test/stripe/charge_test.rb
stripe-4.9.0 test/stripe/charge_test.rb
stripe-4.8.1 test/stripe/charge_test.rb
stripe-4.8.0 test/stripe/charge_test.rb
stripe-4.7.1 test/stripe/charge_test.rb
stripe-4.7.0 test/stripe/charge_test.rb
stripe-4.6.0 test/stripe/charge_test.rb
stripe-4.5.0 test/stripe/charge_test.rb
stripe-4.4.1 test/stripe/charge_test.rb
stripe-4.4.0 test/stripe/charge_test.rb
stripe-4.3.0 test/stripe/charge_test.rb
stripe-4.2.0 test/stripe/charge_test.rb
stripe-4.1.0 test/stripe/charge_test.rb
stripe-4.0.3 test/stripe/charge_test.rb
stripe-4.0.2 test/stripe/charge_test.rb
stripe-4.0.1 test/stripe/charge_test.rb
stripe-4.0.0 test/stripe/charge_test.rb
stripe-3.31.1 test/stripe/charge_test.rb