Sha256: 853e1c1b2f5e742bc8d877f69618c098397b9fffee5cb97f256d48d3f8f64d15

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'test_helper'

class ContactTest < Test::Unit::TestCase
  
  fake_it_all
  
  context "Contact class" do
    should "has correct collection path" do
      assert_equal '/contacts.xml', Contact.collection_path
    end
    should "has correct element path" do
      assert_equal '/contacts/first.xml', Contact.element_path(:first)
      assert_equal '/contacts/1.xml', Contact.element_path(1)
    end
  end
  
  context "Contacts" do
    setup do
      @contacts = Contact.find :all
    end
    should "return an array" do
      assert @contacts.is_a? Array
    end
    should "return Contacts" do
      assert_equal 16, @contacts.size
      assert @contacts.first.is_a? Contact
    end
  end
  
  context "Contact" do
    setup do
      @contact = Contact.find 27309
    end
    should "return a Contact" do
      assert @contact.is_a? Contact
    end
    should "update and save" do
      @contact.last_name = 'Roberts'
      assert @contact.save
    end
    should "be destroyed" do
      assert @contact.destroy
    end
  end
  
  #TODO - Add test for invalid resource
  # Need support from fakeweb in order to achieve this
  
  context "New Contact" do
    setup do
      params = {
        :first_name => 'Fred',
        :last_name  => 'Bloggs'
      }
      @contact = Contact.new params
    end
    should "validate and save" do
      assert @contact.save_with_validation
    end
  end
    
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
freeagent_api-0.3.1 test/contact_test.rb
freeagent_api-0.3.0 test/contact_test.rb
freeagent_api-0.2.0 test/contact_test.rb