Sha256: 0546f178cecfdbf5f0014b31f8a92999e7403fee1a28ef2a9270a586f283ebe0

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 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_key, params|
          url == "#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/recurring_bills" && api_key.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

1 entries across 1 versions & 1 rubygems

Version Path
maestrano-0.3.0 test/maestrano/account/recurring_bill_test.rb