Sha256: 146a3fc979388dab96b2c1dc468b26c6bccb0f82abdf48a858a1b2fde7bc2575

Contents?: true

Size: 1.45 KB

Versions: 34

Compression:

Stored size: 1.45 KB

Contents

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

module Stripe
  class InvoiceTest < Test::Unit::TestCase
    should "retrieve should retrieve invoices" do
      @mock.expects(:get).once.returns(make_response(make_invoice))
      i = Stripe::Invoice.retrieve('in_test_invoice')
      assert_equal 'in_test_invoice', i.id
    end

    should "create should create a new invoice" do
      @mock.expects(:post).once.returns(make_response(make_invoice))
      i = Stripe::Invoice.create
      assert_equal "in_test_invoice", i.id
    end

    should "pay should pay an invoice" do
      @mock.expects(:get).once.returns(make_response(make_invoice))
      i = Stripe::Invoice.retrieve('in_test_invoice')

      @mock.expects(:post).once.with('https://api.stripe.com/v1/invoices/in_test_invoice/pay', nil, '').returns(make_response(make_paid_invoice))
      i.pay
      assert_equal nil, i.next_payment_attempt
    end

    should "pay with extra opts should pay an invoice" do
      @mock.expects(:get).once.returns(make_response(make_invoice))
      i = Stripe::Invoice.retrieve('in_test_invoice', {:api_key => 'foobar'})

      Stripe.expects(:execute_request).with do |opts|
        opts[:url] == "#{Stripe.api_base}/v1/invoices/in_test_invoice/pay" &&
          opts[:method] == :post &&
          opts[:headers][:authorization] == 'Bearer foobar'
      end.returns(make_response(make_paid_invoice))

      i.pay
      assert_equal nil, i.next_payment_attempt
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
stripe-1.43.1 test/stripe/invoice_test.rb
stripe-1.43.0 test/stripe/invoice_test.rb
stripe-1.42.0 test/stripe/invoice_test.rb
stripe-1.41.0 test/stripe/invoice_test.rb
stripe-1.40.0 test/stripe/invoice_test.rb
stripe-1.39.0 test/stripe/invoice_test.rb
stripe-1.38.0 test/stripe/invoice_test.rb
stripe-1.37.0 test/stripe/invoice_test.rb
stripe-1.36.2 test/stripe/invoice_test.rb
stripe-1.36.1 test/stripe/invoice_test.rb
stripe-1.36.0 test/stripe/invoice_test.rb
stripe-1.35.1 test/stripe/invoice_test.rb
stripe-1.35.0 test/stripe/invoice_test.rb
stripe-1.34.0 test/stripe/invoice_test.rb
stripe-1.33.1 test/stripe/invoice_test.rb
stripe-1.33.0 test/stripe/invoice_test.rb
stripe-1.32.1 test/stripe/invoice_test.rb
stripe-1.32.0 test/stripe/invoice_test.rb
stripe-1.31.0 test/stripe/invoice_test.rb
stripe-1.30.3 test/stripe/invoice_test.rb