Sha256: adcbca8f340ae93b56e229b80e499922e300686ccfb5beb49cdea3ac3f1d2bc7

Contents?: true

Size: 1.64 KB

Versions: 13

Compression:

Stored size: 1.64 KB

Contents

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

module Maestrano
  module Account
    class BillTest < Test::Unit::TestCase
      include APITestHelper
      
      should "should be listable" do
        @api_mock.expects(:get).once.returns(test_response(test_account_bill_array))
        c = Maestrano::Account::Bill.all
        assert c.data.kind_of? Array
        c.each do |bill|
          assert bill.kind_of?(Maestrano::Account::Bill)
        end
      end

      should "should be cancellable" do
        @api_mock.expects(:delete).once.returns(test_response(test_account_bill))
        c = Maestrano::Account::Bill.construct_from(test_account_bill[:data])
        c.cancel
      end

      should "should not be updateable" do
        assert_raises NoMethodError do
          @api_mock.stubs(:put).returns(test_response(test_account_bill))
          c = Maestrano::Account::Bill.construct_from(test_account_bill[:data])
          c.save
        end
      end


      should "should successfully create a remote bill when passed correct parameters" do
        @api_mock.expects(:post).with do |url, api_token, params|
          url == "#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills" && api_token.nil? && 
          CGI.parse(params) == {"group_id"=>["cld-1"], "price_cents"=>["23000"], "currency"=>["AUD"], "description"=>["Some bill"]}
        end.once.returns(test_response(test_account_bill))

        bill = Maestrano::Account::Bill.create({
          group_id: 'cld-1',
          price_cents: 23000,
          currency: 'AUD',
          description: 'Some bill'
        })
        assert bill.id
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
maestrano-0.11.0 test/maestrano/account/bill_test.rb
maestrano-0.10.0 test/maestrano/account/bill_test.rb
maestrano-0.9.2 test/maestrano/account/bill_test.rb
maestrano-0.9.1 test/maestrano/account/bill_test.rb
maestrano-0.9.0 test/maestrano/account/bill_test.rb
maestrano-ruby-test-0.8.3 test/maestrano/account/bill_test.rb
maestrano-0.8.2 test/maestrano/account/bill_test.rb
maestrano-0.8.1 test/maestrano/account/bill_test.rb
maestrano-0.8.0 test/maestrano/account/bill_test.rb
maestrano-0.7.0 test/maestrano/account/bill_test.rb
maestrano-0.6.0 test/maestrano/account/bill_test.rb
maestrano-0.5.0 test/maestrano/account/bill_test.rb
maestrano-0.4.0 test/maestrano/account/bill_test.rb