diff --git a/lib/zester.rb b/lib/zester.rb index 869d5f6..7ebf27a 100644 --- a/lib/zester.rb +++ b/lib/zester.rb @@ -3,7 +3,6 @@ require 'zester/client' require 'zester/resource' require 'zester/response' -require 'zester/mortgage' require 'zester/neighborhood' require 'zester/property' require 'zester/valuation' diff --git a/lib/zester/client.rb b/lib/zester/client.rb index b8b1185..4d164eb 100644 --- a/lib/zester/client.rb +++ b/lib/zester/client.rb @@ -28,10 +28,6 @@ def property @property = Zester::Property.new(self) end - def mortgage - @mortgage = Zester::Mortgage.new(self) - end - def valuation @valuation = Zester::Valuation.new(self) end diff --git a/lib/zester/mortgage.rb b/lib/zester/mortgage.rb deleted file mode 100644 index b80f415..0000000 --- a/lib/zester/mortgage.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Zester - class Mortgage < Resource - - def rate_summary(state = nil) - get_results('GetRateSummary', :rate_summary, {'state' => state}) - end - - end -end diff --git a/spec/support/webmock_helper.rb b/spec/support/webmock_helper.rb index 4895087..ae93ab9 100644 --- a/spec/support/webmock_helper.rb +++ b/spec/support/webmock_helper.rb @@ -7,3 +7,7 @@ def new_zester def new_timeout_zester Zester::Client.new(ZWS_ID, 5) end + +def get_response(state = 'CA') + resource.get_results('GetRegionChildren', :regionchildren, state: state) +end diff --git a/spec/zester/client_spec.rb b/spec/zester/client_spec.rb index b0a8597..27bca1c 100644 --- a/spec/zester/client_spec.rb +++ b/spec/zester/client_spec.rb @@ -24,11 +24,6 @@ zester.property.client.should == zester end - it "should return an instance of Zester::Valuatiion for mortgage" do - zester.mortgage.should be_kind_of(Zester::Mortgage) - zester.mortgage.client.should == zester - end - it "should return an instance of Zester::Valuatiion for neighborhood" do zester.neighborhood.should be_kind_of(Zester::Neighborhood) zester.neighborhood.client.should == zester diff --git a/spec/zester/mortgage_spec.rb b/spec/zester/mortgage_spec.rb deleted file mode 100644 index 3a12d48..0000000 --- a/spec/zester/mortgage_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe Zester::Mortgage do - let!(:zester) {new_zester} - let!(:mortgage) {zester.mortgage} - - context "rate_summary" do - it "should be a success" do - VCR.use_cassette('mortgage') do - response = mortgage.rate_summary - response.success?.should be_true - response.today.should_not be_nil - response.last_week.should_not be_nil - end - end - - it "should be a failure" do - VCR.use_cassette('mortgage') do - response = mortgage.rate_summary('XZ') - response.success?.should be_false - response.response_code.should == 501 - response.error_message.should_not be_nil - response.should_not respond_to(:today) - response.should_not respond_to(:last_week) - end - end - end - -end diff --git a/spec/zester/resource_spec.rb b/spec/zester/resource_spec.rb index ada171d..77c0d26 100644 --- a/spec/zester/resource_spec.rb +++ b/spec/zester/resource_spec.rb @@ -11,7 +11,8 @@ context "get_results" do it "should return a response" do VCR.use_cassette('resource') do - response = resource.get_results('GetRateSummary', :rate_summary) + response = get_response + response.success?.should be_true response.should be_instance_of(Zester::Response) end end @@ -27,8 +28,8 @@ end it "should rescue a timeout error" do - stub_request(:get, "http://www.zillow.com/webservice/GetRateSummary.htm?zws-id=#{ZWS_ID}").to_timeout - response = resource.get_results('GetRateSummary', :rate_summary) + stub_request(:get, "http://www.zillow.com/webservice/GetRegionChildren.htm?state=CA&zws-id=#{ZWS_ID}").to_timeout + response = get_response response.success?.should be_false response.message.should_not be_nil response.message.code.should == "3" diff --git a/spec/zester/response_spec.rb b/spec/zester/response_spec.rb index eb0088e..0540ea4 100644 --- a/spec/zester/response_spec.rb +++ b/spec/zester/response_spec.rb @@ -6,7 +6,7 @@ it "should return a success" do VCR.use_cassette('response') do - response = resource.get_results('GetRateSummary', :rate_summary) + response = get_response response.success?.should be_true response.message.should_not be_nil response.message.code.should == "0" @@ -18,28 +18,28 @@ it "should return a failure" do VCR.use_cassette('response') do - response = resource.get_results('GetRateSummary', :rate_summary, {'state' => 'XZ'}) + response = get_response('XZ') response.success?.should be_false response.error_message.should_not be_nil - response.message.code.should == "501" - response.response_code.should == 501 + response.message.code.should == "502" + response.response_code.should == 502 end end context "respond_to?" do it "should respond to methods called from body.response" do VCR.use_cassette('response') do - response = resource.get_results('GetRateSummary', :rate_summary) - response.should respond_to(:today) - response.should respond_to(:last_week) + response = get_response + response.should respond_to(:region) + response.should respond_to(:subregiontype) end end it "should not respond to methods called off body.response" do VCR.use_cassette('response') do - response = resource.get_results('GetRateSummary', :rate_summary, {'state' => 'XZ'}) - response.should_not respond_to(:today) - response.should_not respond_to(:last_week) + response = get_response('XZ') + response.should_not respond_to(:region) + response.should_not respond_to(:subregiontype) end end end @@ -47,16 +47,16 @@ context "method_missing" do it "should call methods off of the body.response" do VCR.use_cassette('response') do - response = resource.get_results('GetRateSummary', :rate_summary) - response.today.should == response.body.response.today + response = get_response + response.subregiontype.should == response.body.response.subregiontype end end it "should raise errors when the method does not exist" do VCR.use_cassette('response') do - response = resource.get_results('GetRateSummary', :rate_summary, {'state' => 'XZ'}) - expect {response.today}.to raise_error(NoMethodError) - expect {response.last_week}.to raise_error(NoMethodError) + response = get_response('XZ') + expect {response.region}.to raise_error(NoMethodError) + expect {response.subregiontype}.to raise_error(NoMethodError) end end end diff --git a/zester.gemspec b/zester.gemspec index c463f75..15ea567 100644 --- a/zester.gemspec +++ b/zester.gemspec @@ -21,10 +21,10 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_dependency 'httparty', '~> 0.12.0' - s.add_dependency "rash", "~> 0.4.0" - s.add_development_dependency "rake", "~> 0.9.2" - s.add_development_dependency "rspec", "~> 2.10.0" - s.add_development_dependency "webmock", "~> 1.8.6" - s.add_development_dependency "vcr", "~> 2.1.1" + s.add_dependency 'httparty', '~> 0.17' + s.add_dependency "rash", "~> 0.4" + s.add_development_dependency "rake", "~> 12.3" + s.add_development_dependency "rspec", "~> 2.10" + s.add_development_dependency "webmock", "~> 3.5" + s.add_development_dependency "vcr", "~> 4.0" end