From 9a877da68226af71354fe652da206abc5e24d8a2 Mon Sep 17 00:00:00 2001 From: martin sarsale Date: Sun, 31 Oct 2010 16:22:30 -0300 Subject: [PATCH] bugfixed estimated_result_count returning always nil --- lib/ruby-web-search.rb | 4 ++-- spec/ruby-web-search_spec.rb | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ruby-web-search.rb b/lib/ruby-web-search.rb index d765dff..fa8e4e3 100644 --- a/lib/ruby-web-search.rb +++ b/lib/ruby-web-search.rb @@ -171,7 +171,7 @@ def process(google_raw_response={}) @results ||= [] @status = google_raw_response["responseStatus"] if google_raw_response["responseData"] && status && status == 200 - estimated_result_count ||= google_raw_response["cursor"]["estimatedResultCount"] if google_raw_response["cursor"] + @estimated_result_count ||= google_raw_response['responseData']["cursor"]["estimatedResultCount"] if google_raw_response['responseData']["cursor"] @results += google_raw_response["responseData"]["results"].map do |r| { :title => r["titleNoFormatting"], @@ -538,4 +538,4 @@ def limit(req_size) end #of Bing -end \ No newline at end of file +end diff --git a/spec/ruby-web-search_spec.rb b/spec/ruby-web-search_spec.rb index b1ff8aa..d0d2fc3 100644 --- a/spec/ruby-web-search_spec.rb +++ b/spec/ruby-web-search_spec.rb @@ -23,6 +23,10 @@ @response.results.size.should == 4 end + it "should have a non nil estimated_result_count" do + @response.estimated_result_count.should_not == nil + end + describe "results" do before(:all) do @results = @response.results @@ -85,4 +89,4 @@ end end -end \ No newline at end of file +end