Sha256: 07573f42eab44e63111a7ff2485d4bcaeaf43b09e669b67ab7ce68d60f49b40f

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 Bytes

Contents

require 'test_helper'

class AvvoApi::PhoneTest < Test::Unit::TestCase

  context "AvvoApi::Phone" do
    should "belong_to :address" do
      assert_contains(AvvoApi::Phone.belongs_to_associations.map(&:attribute), :address)
    end
    
    should "build successfully with PhoneType constants" do
      phone = AvvoApi::Phone.new(:phone_number => '2125551212', :phone_type_id => AvvoApi::PhoneType::OFFICE, :address_id => 1, :lawyer_id => 1)
      assert_equal 2, phone.phone_type_id
    end

    should "be able to return a reasonable string for a phone type id" do
      stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/api/1/lawyers/1/addresses/1/phones/1.json").to_return(:body => {:id => 1, :phone_number => '212-555-1212', :phone_type => 'Office', :updated_at => Time.now}.to_json)
      phone = AvvoApi::Phone.find(1, :params => {:lawyer_id => 1, :address_id => 1})
      assert_equal "Office", phone.phone_type
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avvo_api-0.1.1 test/unit/phone_test.rb
avvo_api-0.1.0 test/unit/phone_test.rb