Sha256: bf9ef06ceee1a7f9611ad5a363e268a602a43ff0724b4337cca5065195d6e965

Contents?: true

Size: 1.82 KB

Versions: 23

Compression:

Stored size: 1.82 KB

Contents

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

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

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

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


      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/recurring_bills" && api_token.nil? && 
          CGI.parse(params) == {"group_id"=>["cld-1"], "price_cents"=>["23000"], "currency"=>["AUD"], "description"=>["Some recurring bill"], "period"=>["Month"]}
        end.once.returns(test_response(test_account_recurring_bill))

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

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
maestrano-1.0.0.pre.RC4 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC3 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC2 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC1 test/maestrano/account/recurring_bill_test.rb
maestrano-0.12.5 test/maestrano/account/recurring_bill_test.rb
maestrano-0.12.4 test/maestrano/account/recurring_bill_test.rb
maestrano-0.12.3 test/maestrano/account/recurring_bill_test.rb
maestrano-0.12.2 test/maestrano/account/recurring_bill_test.rb
maestrano-0.12.1 test/maestrano/account/recurring_bill_test.rb
maestrano-0.12.0 test/maestrano/account/recurring_bill_test.rb
maestrano-0.11.0 test/maestrano/account/recurring_bill_test.rb
maestrano-0.10.0 test/maestrano/account/recurring_bill_test.rb
maestrano-0.9.2 test/maestrano/account/recurring_bill_test.rb
maestrano-0.9.1 test/maestrano/account/recurring_bill_test.rb
maestrano-0.9.0 test/maestrano/account/recurring_bill_test.rb
maestrano-ruby-test-0.8.3 test/maestrano/account/recurring_bill_test.rb
maestrano-0.8.2 test/maestrano/account/recurring_bill_test.rb
maestrano-0.8.1 test/maestrano/account/recurring_bill_test.rb
maestrano-0.8.0 test/maestrano/account/recurring_bill_test.rb
maestrano-0.7.0 test/maestrano/account/recurring_bill_test.rb