-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason Kim
committed
Feb 15, 2013
1 parent
dffffaf
commit 41e2181
Showing
5 changed files
with
33 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ class AvvoApi::BaseTest < Test::Unit::TestCase | |
end | ||
|
||
should "hit the Avvo API with the correct URL when retrieved" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1.json").to_return(:body => {:id => '1'}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1.json").to_return(:body => {:id => '1', :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
AvvoApi::Lawyer.find(1) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1.json") | ||
end | ||
|
@@ -31,7 +31,7 @@ class AvvoApi::BaseTest < Test::Unit::TestCase | |
|
||
context "with a has_one relationship to another object" do | ||
should "hit the associated object's URL with the correct parameters when requested" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah", :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
@object.id = 1 | ||
@object.headshot | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
|
@@ -50,7 +50,7 @@ class AvvoApi::BaseTest < Test::Unit::TestCase | |
end | ||
|
||
should "hit the Avvo API with the correct URL when retrieved" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/specialties/3.json").to_return(:body => {:id => '3'}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/specialties/3.json").to_return(:body => {:id => '3', :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
AvvoApi::Specialty.find(3, :params => {:lawyer_id => 2}) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/specialties/3.json") | ||
end | ||
|
@@ -94,7 +94,7 @@ class AvvoApi::BaseTest < Test::Unit::TestCase | |
@object.lawyer_id = 2 | ||
@object.address_id = 3 | ||
assert_equal 3, @object.address_id | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3.json").to_return(:body => {:id => '3'}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3.json").to_return(:body => {:id => '3', :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
@object.address | ||
@object.address | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3.json", :times => 1) | ||
|
@@ -107,7 +107,7 @@ class AvvoApi::BaseTest < Test::Unit::TestCase | |
end | ||
|
||
should "hit the Avvo API with the correct URL when updated" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3/phones/4.json").to_return(:body => {:id => '4'}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3/phones/4.json").to_return(:body => {:id => '4', :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
phone = AvvoApi::Phone.find(4, :params => {:lawyer_id => 2, :address_id => 3}) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3/phones/4.json") | ||
|
||
|
@@ -125,7 +125,7 @@ class AvvoApi::BaseTest < Test::Unit::TestCase | |
end | ||
|
||
should "hit the Avvo API with the correct URL when retrieved" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3/phones/4.json").to_return(:body => {:id => '4'}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3/phones/4.json").to_return(:body => {:id => '4', :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
AvvoApi::Phone.find(4, :params => {:lawyer_id => 2, :address_id => 3}) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/2/addresses/3/phones/4.json") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ class AvvoApi::HeadshotTest < Test::Unit::TestCase | |
end | ||
|
||
should "get the correct url" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah", :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
AvvoApi::Headshot.find(:one, :params => {:lawyer_id => 1}) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
end | ||
|
@@ -22,15 +22,15 @@ class AvvoApi::HeadshotTest < Test::Unit::TestCase | |
end | ||
|
||
should "be able to update an existing headshot" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah", :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
@headshot = AvvoApi::Headshot.find(:one, :params => {:lawyer_id => 1}) | ||
stub_request(:post, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
stub_request(:put, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
@headshot.save | ||
assert_requested(:post, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
assert_requested(:put, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
end | ||
|
||
should "be able to destroy a headshot" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah", :updated_at => '2013-02-10T00:46:12-08:00'}.to_json) | ||
@headshot = AvvoApi::Headshot.find(:one, :params => {:lawyer_id => 1}) | ||
stub_request(:delete, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/1/headshot.json") | ||
@headshot.destroy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ class AvvoApi::LawyerTest < Test::Unit::TestCase | |
end | ||
|
||
should "have errors on the firstname attribute" do | ||
assert_match "can't be blank", @lawyer.errors.on(:firstname) | ||
assert_match "can't be blank", @lawyer.errors[:firstname].first | ||
end | ||
end | ||
|
||
|
@@ -66,14 +66,14 @@ class AvvoApi::LawyerTest < Test::Unit::TestCase | |
context "AvvoApi::Lawyer.resolve" do | ||
|
||
should "return the appropriate lawyer" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101").to_return(:body => {:lawyers => [{:id => 1}]}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101").to_return(:body => {:lawyers => [{:id => 1}], :annotation => nil}.to_json) | ||
lawyers = AvvoApi::Lawyer.resolve({:name => 'Mark Britton', :zip_code => 98101}) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101") | ||
assert_equal 1, lawyers.length | ||
end | ||
|
||
should "return an empty array if the lawyer can't be found" do | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101").to_return(:body => {:lawyers => []}.to_json) | ||
stub_request(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101").to_return(:body => {:lawyers => [], :annotation => nil}.to_json) | ||
lawyers = AvvoApi::Lawyer.resolve({:name => 'Mark Britton', :zip_code => 98101}) | ||
assert_requested(:get, "https://test_account%40avvo.com:[email protected]/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101") | ||
assert_equal 0, lawyers.length | ||
|