spec/cli/search_spec.rb in t-0.3.1 vs spec/cli/search_spec.rb in t-0.4.0
- old
+ new
@@ -2,18 +2,22 @@
require 'helper'
describe T::CLI::Search do
before do
+ rcfile = RCFile.instance
+ rcfile.path = fixture_path + "/.trc"
@t = T::CLI.new
@old_stderr = $stderr
$stderr = StringIO.new
@old_stdout = $stdout
$stdout = StringIO.new
+ Timecop.freeze(Time.local(2011, 11, 24, 16, 20, 0))
end
after do
+ Timecop.return
$stderr = @old_stderr
$stdout = @old_stdout
end
describe "#all" do
@@ -45,9 +49,237 @@
twittag: [Twitter*feed] 『かちびと.net』 の人気エントリー - はてなブックマーク http://bit.ly/9Yx6xS (about 1 year ago)
avexnews: @ICONIQ_NEWS opened!She gain attention by collaboration song「I'm lovin' you」wif EXILE・ATSUSHI.Get her newest info here! http://bit.ly/dymm8v (about 1 year ago)
WildIvory92: RT @FiercePrinceJ: People on Twitter Gossip about other People, Hate others? This Is Twitter Nothing More, Nothing Less. (about 1 year ago)
twittag: [Twitter*feed] Now Playing Friends - リニューアル式 : R49 http://bit.ly/bmlA5g (about 1 year ago)
eos
+ end
+ end
+
+ describe "#favorites" do
+ it "should request the correct resource" do
+ 1.upto(16).each do |page|
+ stub_get("/1/favorites.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ @t.search("favorites", "twitter")
+ 1.upto(16).each do |page|
+ a_get("/1/favorites.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ should have_been_made
+ end
+ end
+ it "should have the correct output" do
+ 1.upto(16).each do |page|
+ stub_get("/1/favorites.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ @t.search("favorites", "twitter")
+ $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ eos
+ end
+ context "Twitter is down" do
+ it "should retry 3 times and then raise an error" do
+ 1.upto(15).each do |page|
+ stub_get("/1/favorites.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ stub_get("/1/favorites.json").
+ with(:query => {:count => "200", :page => "16"}).
+ to_return(:status => 502)
+ lambda do
+ @t.search("favorites", "twitter")
+ end.should raise_error("Twitter is down or being upgraded.")
+ a_get("/1/favorites.json").
+ with(:query => {:count => "200", :page => "16"}).
+ should have_been_made.times(3)
+ end
+ end
+ end
+
+ describe "#mentions" do
+ it "should request the correct resource" do
+ 1.upto(16).each do |page|
+ stub_get("/1/statuses/mentions.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ @t.search("mentions", "twitter")
+ 1.upto(16).each do |page|
+ a_get("/1/statuses/mentions.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ should have_been_made
+ end
+ end
+ it "should have the correct output" do
+ 1.upto(16).each do |page|
+ stub_get("/1/statuses/mentions.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ @t.search("mentions", "twitter")
+ $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ eos
+ end
+ context "Twitter is down" do
+ it "should retry 3 times and then raise an error" do
+ 1.upto(15).each do |page|
+ stub_get("/1/statuses/mentions.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ stub_get("/1/statuses/mentions.json").
+ with(:query => {:count => "200", :page => "16"}).
+ to_return(:status => 502)
+ lambda do
+ @t.search("mentions", "twitter")
+ end.should raise_error("Twitter is down or being upgraded.")
+ a_get("/1/statuses/mentions.json").
+ with(:query => {:count => "200", :page => "16"}).
+ should have_been_made.times(3)
+ end
+ end
+ end
+
+ describe "#retweets" do
+ it "should request the correct resource" do
+ 1.upto(16).each do |page|
+ stub_get("/1/statuses/retweeted_by_me.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ @t.search("retweets", "twitter")
+ 1.upto(16).each do |page|
+ a_get("/1/statuses/retweeted_by_me.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ should have_been_made
+ end
+ end
+ it "should have the correct output" do
+ 1.upto(16).each do |page|
+ stub_get("/1/statuses/retweeted_by_me.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ @t.search("retweets", "twitter")
+ $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
+ eos
+ end
+ context "Twitter is down" do
+ it "should retry 3 times and then raise an error" do
+ 1.upto(15).each do |page|
+ stub_get("/1/statuses/retweeted_by_me.json").
+ with(:query => {:count => "200", :page => "#{page}"}).
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ stub_get("/1/statuses/retweeted_by_me.json").
+ with(:query => {:count => "200", :page => "16"}).
+ to_return(:status => 502)
+ lambda do
+ @t.search("retweets", "twitter")
+ end.should raise_error("Twitter is down or being upgraded.")
+ a_get("/1/statuses/retweeted_by_me.json").
+ with(:query => {:count => "200", :page => "16"}).
+ should have_been_made.times(3)
+ end
end
end
describe "#timeline" do
it "should request the correct resource" do