spec/googleajax_common.rb in googleajax-0.2.0 vs spec/googleajax_common.rb in googleajax-1.0.0

- old
+ new

@@ -11,11 +11,11 @@ GoogleAjax.referer = "http://example.com" @response = GoogleAjax::Search.web("apple", :rsz => :large) end it "returns the expected results" do - @response['results'].select{|result| result['url'] =~ /http:(.*).apple.com/}.size.should >= 4 + @response[:results].select{|result| result[:url] =~ /http:(.*).apple.com/}.size.should >= 4 end end { :blogs => 100_000, @@ -31,11 +31,11 @@ @response_small = GoogleAjax::Search.send(method, "ruby", *args) end it "takes options into account" do @response_large = GoogleAjax::Search.send(method, "ruby", *(args+[{:rsz => :large}])) - @response_large['results'].size.should > @response_small['results'].size + @response_large[:results].size.should > @response_small[:results].size end unless method == :blogs # Google doesn't seem to support this option for blogs??? it "returns an approximate count of hits" do @response_small.count.should > min end @@ -48,18 +48,24 @@ GoogleAjax.referer = "http://example.com" end describe ".detect" do it "returns the right language" do - GoogleAjax::Language.detect("What's up folks")['language'].should == "en" - GoogleAjax::Language.detect("Montréal est une ville incroyable")['language'].should == "fr" + GoogleAjax::Language.detect("What's up folks")[:language].should == "en" + GoogleAjax::Language.detect("Montréal est une ville incroyable")[:language].should == "fr" end + + it "converts nicely the return types" do + result = GoogleAjax::Language.detect("Sandwich") + result[:is_reliable].should == false + result[:confidence].should be_a(Numeric) + end end describe ".translate" do it "does an approximate translation" do - GoogleAjax::Language.translate("Ruby rocks", "en", "fr")['translatedText'].should == "Ruby roches" + GoogleAjax::Language.translate("Ruby rocks", "en", "fr")[:translated_text].should == "Ruby roches" end end end describe "::Feed" do @@ -69,25 +75,25 @@ describe ".find" do it "returns the right feeds" do feeds = GoogleAjax::Feed.find("Ruby") feeds.size.should == 10 - feeds.any?{|result| result['url'] == "http://www.ruby-lang.org/en/feeds/news.rss"}.should be_true + feeds.any?{|result| result[:url] == "http://ruby-lang.org/en/feeds/news.rss"}.should be_true end end describe ".load" do it "loads entries of a feed" do feed = GoogleAjax::Feed.load('http://digg.com/rss/index.xml') - feed['title'].should == "digg.com: Stories / Popular" - feed['entries'].size.should == 4 + feed[:title].should == "digg.com: Stories / Popular" + feed[:entries].size.should == 4 end end describe ".lookup" do it "returns the feed associated with a URL" do feed = GoogleAjax::Feed.lookup("http://digg.com/") - feed['url'].should == "http://feeds.digg.com/digg/popular.rss" + feed[:url].should == "http://feeds.digg.com/digg/popular.rss" end end end end