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

- old
+ new

@@ -15,10 +15,24 @@ it "returns the expected results" do @response[:results].select{|result| result[:url] =~ /http:(.*).apple.com/}.size.should >= 4 end end + describe ".news" do + before :each do + GoogleAjax.referer = "http://example.com" + end + + it "returns fresh news" do + one_day = 24 * 60 * 60 + yesterday = Time.now - one_day + results = GoogleAjax::Search.news("", :topic => :h)[:results] + results.size.should >= 4 + results.all?{|r| r[:published_date].should >= yesterday} + end + end + { :blogs => 100_000, :books => 10_000, :images => 10_000, :video => 10_000, @@ -63,10 +77,14 @@ describe ".translate" do it "does an approximate translation" do GoogleAjax::Language.translate("Ruby rocks", "en", "fr")[:translated_text].should == "Ruby roches" end + + it "translates texts longer than the 2k limit on get requets" do + GoogleAjax::Language.translate("Ruby rocks. "*250, "en", "fr")[:translated_text].count("Ruby").should == 1000 + end end end describe "::Feed" do before :each do @@ -75,10 +93,10 @@ describe ".find" do it "returns the right feeds" do feeds = GoogleAjax::Feed.find("Ruby") feeds.size.should == 10 - feeds.any?{|result| result[:url] == "http://ruby-lang.org/en/feeds/news.rss"}.should be_true + feeds.map{|f| f[:url]}.should include "http://www.ruby-lang.org/en/feeds/news.rss" end end describe ".load" do it "loads entries of a feed" do