diff --git a/Gemfile.lock b/Gemfile.lock index 5ec6891..b5a1ba4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,27 +2,30 @@ PATH remote: . specs: avvo_api (0.2.0) - activeresource (~> 3.0.0) - reactive_resource (~> 0.5) + activeresource (>= 3.0.0) + reactive_resource (~> 0.7) GEM remote: http://rubygems.org/ specs: - activemodel (3.0.6) - activesupport (= 3.0.6) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activeresource (3.0.6) - activemodel (= 3.0.6) - activesupport (= 3.0.6) - activesupport (3.0.6) + activemodel (3.2.12) + activesupport (= 3.2.12) + builder (~> 3.0.0) + activeresource (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) + activesupport (3.2.12) + i18n (~> 0.6) + multi_json (~> 1.0) addressable (2.2.2) - builder (2.1.2) + builder (3.0.4) crack (0.1.8) - i18n (0.5.0) + i18n (0.6.1) + multi_json (1.6.1) rake (0.8.7) - reactive_resource (0.6.0) - activeresource (>= 2.3.10) + reactive_resource (0.7.1) + activeresource (>= 3.1) + activesupport (>= 3.1) shoulda (2.11.3) webmock (1.6.2) addressable (>= 2.2.2) diff --git a/avvo_api.gemspec b/avvo_api.gemspec index f55b51d..6182e94 100644 --- a/avvo_api.gemspec +++ b/avvo_api.gemspec @@ -12,8 +12,8 @@ Gem::Specification.new do |s| s.summary = %q{An ActiveResource client to the Avvo API} s.description = %q{An ActiveResource client to the Avvo API} - s.add_dependency "activeresource", '~> 3.0.0' - s.add_dependency "reactive_resource", '~> 0.5' + s.add_dependency "activeresource", '>= 3.0.0' + s.add_dependency "reactive_resource", '~> 0.7' s.add_development_dependency "shoulda", '~> 2.11.3' s.add_development_dependency "webmock", '~> 1.6.1' diff --git a/test/unit/base_test.rb b/test/unit/base_test.rb index 0c3e6e1..ce66de8 100644 --- a/test/unit/base_test.rb +++ b/test/unit/base_test.rb @@ -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:password@api.avvo.com/api/1/lawyers/1.json").to_return(:body => {:id => '1'}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/2/specialties/3.json").to_return(:body => {:id => '3'}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/2/addresses/3.json").to_return(:body => {:id => '3'}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/2/addresses/3/phones/4.json").to_return(:body => {:id => '4'}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/2/addresses/3/phones/4.json").to_return(:body => {:id => '4'}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/2/addresses/3/phones/4.json") end diff --git a/test/unit/headshot_test.rb b/test/unit/headshot_test.rb index 5f48af2..2a4dda5 100644 --- a/test/unit/headshot_test.rb +++ b/test/unit/headshot_test.rb @@ -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:password@api.avvo.com/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/1/headshot.json") + stub_request(:put, "https://test_account%40avvo.com:password@api.avvo.com/api/1/lawyers/1/headshot.json") @headshot.save - assert_requested(:post, "https://test_account%40avvo.com:password@api.avvo.com/api/1/lawyers/1/headshot.json") + assert_requested(:put, "https://test_account%40avvo.com:password@api.avvo.com/api/1/lawyers/1/headshot.json") end should "be able to destroy a headshot" do - stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/api/1/lawyers/1/headshot.json").to_return(:body => {:headshot_url => "blah"}.to_json) + stub_request(:get, "https://test_account%40avvo.com:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/1/headshot.json") @headshot.destroy diff --git a/test/unit/lawyer_test.rb b/test/unit/lawyer_test.rb index 16f4eef..dce91d6 100644 --- a/test/unit/lawyer_test.rb +++ b/test/unit/lawyer_test.rb @@ -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:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/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:password@api.avvo.com/api/1/lawyers/resolve.json?params%5Bname%5D=Mark%20Britton¶ms%5Bzip_code%5D=98101") assert_equal 0, lawyers.length