Skip to content

Commit

Permalink
Updating gems and fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Kim committed Feb 15, 2013
1 parent dffffaf commit 41e2181
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
31 changes: 17 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions avvo_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
12 changes: 6 additions & 6 deletions test/unit/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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")

Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/unit/headshot_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/unit/lawyer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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&params%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&params%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&params%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&params%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&params%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&params%5Bzip_code%5D=98101")
assert_equal 0, lawyers.length
Expand Down

0 comments on commit 41e2181

Please sign in to comment.