Sha256: 78e9069029c524e9ed7c596d26bf9238592b2b947735d80f79329456af4333d4

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

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

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

    should "customers should be deletable" do
      @mock.expects(:delete).once.returns(test_response(test_customer({:deleted => true})))
      c = SweetTooth::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({:email => "lmessi@example.com"})))
      @mock.expects(:post).once.returns(test_response(test_customer({:email => "cronaldo@example.com"})))
      c = SweetTooth::Customer.new("test_customer").refresh
      assert_equal c.email, "lmessi@example.com"
      c.email = "cronaldo@example.com"
      c.save
      assert_equal c.email, "cronaldo@example.com"
    end

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sweettooth-1.1.0 test/sweettooth/customer_test.rb
sweettooth-1.0.0 test/sweettooth/customer_test.rb