Sha256: a8fb935bb07a715af35702fdeb9dcff18f61d326fee734a7aff6edad92436e47

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

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

module Paid
  class CustomerTest < Test::Unit::TestCase
    should "customers should be listable" do
      @mock.expects(:get).once.returns(test_response(test_customer_array))
      c = Paid::Customer.all.data
      assert c.kind_of? Array
      assert c[0].kind_of? Paid::Customer
    end

    should "customers should be deletable" do
      @mock.expects(:delete).once.returns(test_response(test_customer({:deleted => true})))
      c = Paid::Customer.new("test_customer")
      c.delete
      assert c.deleted
    end

    should "customers should be updateable" do
      @mock.expects(:get).once.returns(test_response(test_customer({:mnemonic => "foo"})))
      @mock.expects(:post).once.returns(test_response(test_customer({:mnemonic => "bar"})))
      c = Paid::Customer.new("test_customer").refresh
      assert_equal "foo", c.mnemonic
      c.mnemonic = "bar"
      c.save
      assert_equal "bar", c.mnemonic
    end

    should "create should return a new customer" do
      @mock.expects(:post).once.returns(test_response(test_customer))
      c = Paid::Customer.create
      assert_equal "cus_test_customer", c.id
    end

    should "be able to generate invoice" do
      @mock.expects(:get).never
      @mock.expects(:post).once.returns(test_response(test_customer))
      c = Paid::Customer.create
      @mock.expects(:post).once.returns(test_response(test_invoice))
      i = c.generate_invoice
      assert i.kind_of?(Paid::Invoice)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paid-0.1.0 test/paid/customer_test.rb