Skip to content

Commit

Permalink
Add specs for --unsorted option
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Apr 26, 2012
1 parent 4e986ae commit bc3a91c
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 16 deletions.
7 changes: 0 additions & 7 deletions lib/t/list.rb
Expand Up @@ -94,17 +94,10 @@ def remove(list_name, screen_name, *screen_names)
end

desc "timeline [SCREEN_NAME] LIST_NAME", "Show tweet timeline for members of the specified list."
method_option :created, :aliases => "-c", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter acount was created."
method_option :favorites, :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by total number of favorites."
method_option :followers, :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by total number of followers."
method_option :friends, :aliases => "-d", :type => :boolean, :default => false, :desc => "Sort by total number of friends."
method_option :id, :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify input as a Twitter user ID instead of a screen name."
method_option :listed, :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
method_option :long, :aliases => "-l", :type => :boolean, :default => false, :desc => "List in long format."
method_option :number, :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
method_option :reverse, :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
method_option :tweets, :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by total number of Tweets."
method_option :unsorted, :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
def timeline(*args)
list = args.pop
owner = args.pop || @rcfile.default_profile[0]
Expand Down
72 changes: 72 additions & 0 deletions spec/cli_spec.rb
Expand Up @@ -372,6 +372,15 @@
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.disciples
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "with a user passed" do
before do
stub_get("/1/followers/ids.json").
Expand Down Expand Up @@ -783,6 +792,15 @@
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.followings
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "with a user passed" do
before do
stub_get("/1/friends/ids.json").
Expand Down Expand Up @@ -920,6 +938,15 @@
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.followers
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "with a user passed" do
before do
stub_get("/1/followers/ids.json").
Expand Down Expand Up @@ -1066,6 +1093,15 @@
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.friends
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "with a user passed" do
before do
stub_get("/1/friends/ids.json").
Expand Down Expand Up @@ -1221,6 +1257,15 @@
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.leaders
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "with a user passed" do
before do
stub_get("/1/friends/ids.json").
Expand Down Expand Up @@ -1829,6 +1874,15 @@
$stdout.string.rstrip.should == "@stuntmann82 @antpires @jtrupiano @maccman @mlroach"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.suggest
$stdout.string.rstrip.should == "@jtrupiano @mlroach @antpires @maccman @stuntmann82"
end
end
context "with a user passed" do
it "should request the correct resource" do
@cli.suggest("sferik")
Expand Down Expand Up @@ -2101,6 +2155,15 @@
$stdout.string.rstrip.should == "Worldwide United States San Francisco New York Boston"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.trend_locations
$stdout.string.rstrip.should == "Boston Worldwide New York United States San Francisco"
end
end
end

describe "#unfollow" do
Expand Down Expand Up @@ -2294,6 +2357,15 @@
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@cli.options = @cli.options.merge(:unsorted => true)
end
it "should not be sorted" do
@cli.users("sferik", "pengwynn")
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
end

describe "#version" do
Expand Down
27 changes: 18 additions & 9 deletions spec/list_spec.rb
Expand Up @@ -105,15 +105,15 @@
end
it "should have the correct output" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@pengwynn @sferik"
$stdout.string.rstrip.should == "@pengwynn @sferik"
end
context "--created" do
before do
@list.options = @list.options.merge(:created => true)
end
it "should sort by the time wshen Twitter account was created" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@sferik @pengwynn"
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--favorites" do
Expand All @@ -122,7 +122,7 @@
end
it "should sort by number of favorites" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@pengwynn @sferik"
$stdout.string.rstrip.should == "@pengwynn @sferik"
end
end
context "--followers" do
Expand All @@ -131,7 +131,7 @@
end
it "should sort by number of followers" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@sferik @pengwynn"
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--friends" do
Expand All @@ -140,7 +140,7 @@
end
it "should sort by number of friends" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@sferik @pengwynn"
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--listed" do
Expand All @@ -149,7 +149,7 @@
end
it "should sort by number of list memberships" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@sferik @pengwynn"
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--long" do
Expand All @@ -171,7 +171,7 @@
end
it "should reverse the order of the sort" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@sferik @pengwynn"
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--tweets" do
Expand All @@ -180,7 +180,16 @@
end
it "should sort by number of Tweets" do
@list.members("presidents")
$stdout.string.chomp.rstrip.should == "@sferik @pengwynn"
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "--unsorted" do
before do
@list.options = @list.options.merge(:unsorted => true)
end
it "should not be sorted" do
@list.members("presidents")
$stdout.string.rstrip.should == "@sferik @pengwynn"
end
end
context "with a user passed" do
Expand All @@ -197,7 +206,7 @@
end
it "should have the correct output" do
@list.members("sferik", "presidents")
$stdout.string.chomp.rstrip.should == "@pengwynn @sferik"
$stdout.string.rstrip.should == "@pengwynn @sferik"
end
context "--id" do
before do
Expand Down

0 comments on commit bc3a91c

Please sign in to comment.