t 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,11 @@
1
1
  class String
2
2
 
3
- def strip_at
3
+ def strip_ats
4
4
  self.tr('@', '')
5
5
  end
6
6
 
7
+ def strip_commas
8
+ self.tr(',', '')
9
+ end
10
+
7
11
  end
@@ -18,7 +18,7 @@ module T
18
18
  def block(screen_name, *screen_names)
19
19
  screen_names.unshift(screen_name)
20
20
  screen_names.threaded_each do |screen_name|
21
- screen_name.strip_at
21
+ screen_name.strip_ats
22
22
  retryable(:tries => 3, :on => Twitter::Error::ServerError, :sleep => 0) do
23
23
  client.unblock(screen_name, :include_entities => false)
24
24
  end
@@ -28,17 +28,17 @@ module T
28
28
  say "Run `#{File.basename($0)} block #{screen_names.join(' ')}` to block."
29
29
  end
30
30
 
31
- desc "dm", "Delete the last Direct Message sent."
32
- def dm
33
- direct_message = client.direct_messages_sent(:count => 1, :include_entities => false).first
34
- if direct_message
35
- unless parent_options['force']
31
+ desc "dm [DIRECT_MESSAGE_ID] [DIRECT_MESSAGE_ID...]", "Delete the last Direct Message sent."
32
+ def dm(direct_message_id, *direct_message_ids)
33
+ direct_message_ids.unshift(direct_message_id)
34
+ direct_message_ids.map!(&:strip_commas).map!(&:to_i)
35
+ direct_message_ids.each do |direct_message_id|
36
+ unless options['force']
37
+ direct_message = client.direct_message(direct_message_id, :include_entities => false)
36
38
  return unless yes? "Are you sure you want to permanently delete the direct message to @#{direct_message.recipient.screen_name}: \"#{direct_message.text}\"? [y/N]"
37
39
  end
38
- direct_message = client.direct_message_destroy(direct_message.id, :include_entities => false)
39
- say "@#{direct_message.sender.screen_name} deleted the direct message sent to @#{direct_message.recipient.screen_name}: \"#{direct_message.text}\""
40
- else
41
- raise Thor::Error, "Direct Message not found"
40
+ direct_message = client.direct_message_destroy(direct_message_id, :include_entities => false)
41
+ say "@#{@rcfile.default_profile[0]} deleted the direct message sent to @#{direct_message.recipient.screen_name}: \"#{direct_message.text}\""
42
42
  end
43
43
  end
44
44
  map %w(m) => :dm
@@ -47,7 +47,7 @@ module T
47
47
  def favorite(status_id, *status_ids)
48
48
  status_ids.unshift(status_id)
49
49
  status_ids.each do |status_id|
50
- unless parent_options['force']
50
+ unless options['force']
51
51
  status = client.status(status_id, :include_entities => false, :include_my_retweet => false, :trim_user => true)
52
52
  return unless yes? "Are you sure you want to delete the favorite of @#{status.user.screen_name}'s status: \"#{status.text}\"? [y/N]"
53
53
  end
@@ -59,7 +59,7 @@ module T
59
59
 
60
60
  desc "list LIST_NAME", "Delete a list."
61
61
  def list(list_name)
62
- unless parent_options['force']
62
+ unless options['force']
63
63
  return unless yes? "Are you sure you want to permanently delete the list \"#{list_name}\"? [y/N]"
64
64
  end
65
65
  status = client.list_destroy(list_name)
@@ -70,7 +70,7 @@ module T
70
70
  def status(status_id, *status_ids)
71
71
  status_ids.unshift(status_id)
72
72
  status_ids.each do |status_id|
73
- unless parent_options['force']
73
+ unless options['force']
74
74
  status = client.status(status_id, :include_entities => false, :include_my_retweet => false, :trim_user => true)
75
75
  return unless yes? "Are you sure you want to permanently delete @#{status.user.screen_name}'s status: \"#{status.text}\"? [y/N]"
76
76
  end
@@ -1,8 +1,10 @@
1
1
  require 'action_view'
2
2
  require 'active_support/core_ext/array/grouping'
3
3
  require 'retryable'
4
+ require 't/collectable'
4
5
  require 't/core_ext/enumerable'
5
6
  require 't/core_ext/string'
7
+ require 't/printable'
6
8
  require 't/rcfile'
7
9
  require 't/requestable'
8
10
  require 'thor'
@@ -10,6 +12,8 @@ require 'thor'
10
12
  module T
11
13
  class List < Thor
12
14
  include ActionView::Helpers::DateHelper
15
+ include T::Collectable
16
+ include T::Printable
13
17
  include T::Requestable
14
18
 
15
19
  DEFAULT_NUM_RESULTS = 20
@@ -24,19 +28,19 @@ module T
24
28
  @rcfile = RCFile.instance
25
29
  end
26
30
 
27
- desc "add LIST_NAME SCREEN_NAME [SCREEN_NAME...]", "Add users to a list."
31
+ desc "add LIST_NAME SCREEN_NAME [SCREEN_NAME...]", "Add members to a list."
28
32
  def add(list_name, screen_name, *screen_names)
29
33
  screen_names.unshift(screen_name)
30
- screen_names.map!(&:strip_at)
34
+ screen_names.map!(&:strip_ats)
31
35
  screen_names.in_groups_of(MAX_USERS_PER_REQUEST, false).threaded_each do |user_id_group|
32
36
  retryable(:tries => 3, :on => Twitter::Error::ServerError, :sleep => 0) do
33
37
  client.list_add_members(list_name, user_id_group)
34
38
  end
35
39
  end
36
40
  number = screen_names.length
37
- say "@#{@rcfile.default_profile[0]} added #{number} #{number == 1 ? 'user' : 'users'} to the list \"#{list_name}\"."
41
+ say "@#{@rcfile.default_profile[0]} added #{number} #{number == 1 ? 'member' : 'members'} to the list \"#{list_name}\"."
38
42
  say
39
- say "Run `#{File.basename($0)} list remove users #{list_name} #{screen_names.join(' ')}` to undo."
43
+ say "Run `#{File.basename($0)} list remove #{list_name} #{screen_names.join(' ')}` to undo."
40
44
  end
41
45
 
42
46
  desc "create LIST_NAME [DESCRIPTION]", "Create a new list."
@@ -48,54 +52,57 @@ module T
48
52
  say "@#{@rcfile.default_profile[0]} created the list \"#{list_name}\"."
49
53
  end
50
54
 
51
- # Remove
52
- desc "remove LIST_NAME SCREEN_NAME [SCREEN_NAME...]", "Remove users from a list."
55
+ desc "members [SCREEN_NAME] LIST_NAME", "Returns the members of a Twitter list."
56
+ method_option :created, :aliases => "-c", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter acount was created."
57
+ method_option :favorites, :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by total number of favorites."
58
+ method_option :followers, :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by total number of followers."
59
+ method_option :friends, :aliases => "-d", :type => :boolean, :default => false, :desc => "Sort by total number of friends."
60
+ method_option :listed, :aliases => "-i", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
61
+ method_option :long, :aliases => "-l", :type => :boolean, :default => false, :desc => "List in long format."
62
+ method_option :reverse, :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
63
+ method_option :tweets, :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by total number of Tweets."
64
+ method_option :unsorted, :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
65
+ def members(*args)
66
+ list = args.pop
67
+ owner = args.pop || @rcfile.default_profile[0]
68
+ users = collect_with_cursor do |cursor|
69
+ client.list_members(owner, list, :cursor => cursor, :include_entities => false, :skip_status => true)
70
+ end
71
+ print_user_list(users)
72
+ end
73
+
74
+ desc "remove LIST_NAME SCREEN_NAME [SCREEN_NAME...]", "Remove members from a list."
53
75
  def remove(list_name, screen_name, *screen_names)
54
76
  screen_names.unshift(screen_name)
55
- screen_names.map!(&:strip_at)
77
+ screen_names.map!(&:strip_ats)
56
78
  screen_names.in_groups_of(MAX_USERS_PER_REQUEST, false).threaded_each do |user_id_group|
57
79
  retryable(:tries => 3, :on => Twitter::Error::ServerError, :sleep => 0) do
58
80
  client.list_remove_members(list_name, user_id_group)
59
81
  end
60
82
  end
61
83
  number = screen_names.length
62
- say "@#{@rcfile.default_profile[0]} removed #{number} #{number == 1 ? 'user' : 'users'} from the list \"#{list_name}\"."
84
+ say "@#{@rcfile.default_profile[0]} removed #{number} #{number == 1 ? 'member' : 'members'} from the list \"#{list_name}\"."
63
85
  say
64
- say "Run `#{File.basename($0)} list add users #{list_name} #{screen_names.join(' ')}` to undo."
86
+ say "Run `#{File.basename($0)} list add #{list_name} #{screen_names.join(' ')}` to undo."
65
87
  end
66
88
 
67
89
  desc "timeline [SCREEN_NAME] LIST_NAME", "Show tweet timeline for members of the specified list."
68
90
  method_option :created, :aliases => "-c", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter acount was created."
69
- method_option :friends, :aliases => "-d", :type => :boolean, :default => false, :desc => "Sort by total number of friends."
91
+ method_option :favorites, :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by total number of favorites."
70
92
  method_option :followers, :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by total number of followers."
93
+ method_option :friends, :aliases => "-d", :type => :boolean, :default => false, :desc => "Sort by total number of friends."
71
94
  method_option :listed, :aliases => "-i", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
72
95
  method_option :long, :aliases => "-l", :type => :boolean, :default => false, :desc => "List in long format."
73
- method_option :number, :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS
96
+ method_option :number, :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
74
97
  method_option :reverse, :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
75
98
  method_option :tweets, :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by total number of Tweets."
76
99
  method_option :unsorted, :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
77
- method_option :favorites, :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by total number of favorites."
78
100
  def timeline(*args)
79
101
  list = args.pop
80
102
  owner = args.pop || @rcfile.default_profile[0]
81
103
  per_page = options['number'] || DEFAULT_NUM_RESULTS
82
104
  statuses = client.list_timeline(owner, list, :include_entities => false, :per_page => per_page)
83
- statuses.reverse! if options['reverse']
84
- if options['long']
85
- array = statuses.map do |status|
86
- created_at = status.created_at > 6.months.ago ? status.created_at.strftime("%b %e %H:%M") : status.created_at.strftime("%b %e %Y")
87
- [status.id.to_s, created_at, status.user.screen_name, status.text.gsub(/\n+/, ' ')]
88
- end
89
- if STDOUT.tty?
90
- headings = ["ID", "Created at", "Screen name", "Text"]
91
- array.unshift(headings)
92
- end
93
- print_table(array)
94
- else
95
- statuses.each do |status|
96
- say "#{status.user.screen_name.rjust(MAX_SCREEN_NAME_SIZE)}: #{status.text.gsub(/\n+/, ' ')} (#{time_ago_in_words(status.created_at)} ago)"
97
- end
98
- end
105
+ print_status_list(statuses)
99
106
  end
100
107
  map %w(tl) => :timeline
101
108
 
@@ -0,0 +1,82 @@
1
+ require 'action_view'
2
+ require 'highline'
3
+
4
+ module T
5
+ module Printable
6
+ MAX_SCREEN_NAME_SIZE = 20
7
+ include ActionView::Helpers::NumberHelper
8
+
9
+ def self.included(base)
10
+
11
+ private
12
+
13
+ def print_in_columns(array)
14
+ cols = HighLine::SystemExtensions.terminal_size[0]
15
+ width = (array.map{|el| el.to_s.size}.max || 0) + 2
16
+ array.each_with_index do |value, index|
17
+ puts if (((index) % (cols / width))).zero? && !index.zero?
18
+ printf("%-#{width}s", value)
19
+ end
20
+ puts
21
+ end
22
+
23
+ def print_status_list(statuses)
24
+ statuses.reverse! if options['reverse']
25
+ if options['long']
26
+ array = statuses.map do |status|
27
+ created_at = status.created_at > 6.months.ago ? status.created_at.strftime("%b %e %H:%M") : status.created_at.strftime("%b %e %Y")
28
+ [number_with_delimiter(status.id), created_at, status.user.screen_name, status.text.gsub(/\n+/, ' ')]
29
+ end
30
+ if STDOUT.tty?
31
+ headings = ["ID", "Posted at", "Screen name", "Text"]
32
+ array.unshift(headings) unless statuses.empty?
33
+ end
34
+ print_table(array)
35
+ else
36
+ statuses.each do |status|
37
+ say "#{status.user.screen_name.rjust(MAX_SCREEN_NAME_SIZE)}: #{status.text.gsub(/\n+/, ' ')} (#{time_ago_in_words(status.created_at)} ago)"
38
+ end
39
+ end
40
+ end
41
+
42
+ def print_user_list(users)
43
+ users = users.sort_by{|user| user.screen_name.downcase} unless options['unsorted']
44
+ if options['created']
45
+ users = users.sort_by{|user| user.created_at}
46
+ elsif options['favorites']
47
+ users = users.sort_by{|user| user.favourites_count}
48
+ elsif options['followers']
49
+ users = users.sort_by{|user| user.followers_count}
50
+ elsif options['friends']
51
+ users = users.sort_by{|user| user.friends_count}
52
+ elsif options['listed']
53
+ users = users.sort_by{|user| user.listed_count}
54
+ elsif options['tweets']
55
+ users = users.sort_by{|user| user.statuses_count}
56
+ end
57
+ users.reverse! if options['reverse']
58
+ if options['long']
59
+ array = users.map do |user|
60
+ created_at = user.created_at > 6.months.ago ? user.created_at.strftime("%b %e %H:%M") : user.created_at.strftime("%b %e %Y")
61
+ [number_with_delimiter(user.id), created_at, number_with_delimiter(user.statuses_count), number_with_delimiter(user.favourites_count), number_with_delimiter(user.listed_count), number_with_delimiter(user.friends_count), number_with_delimiter(user.followers_count), user.screen_name, user.name]
62
+ end
63
+ if STDOUT.tty?
64
+ headings = ["ID", "Since", "Tweets", "Favorites", "Listed", "Following", "Followers", "Screen name", "Name"]
65
+ array.unshift(headings) unless users.empty?
66
+ end
67
+ print_table(array)
68
+ else
69
+ if STDOUT.tty?
70
+ print_in_columns(users.map(&:screen_name))
71
+ else
72
+ users.each do |user|
73
+ say user.screen_name
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+ end
82
+ end
@@ -15,7 +15,7 @@ module T
15
15
 
16
16
  def client
17
17
  return @client if @client
18
- @rcfile.path = parent_options['profile'] if parent_options['profile']
18
+ @rcfile.path = options['profile'] if options['profile']
19
19
  @client = Twitter::Client.new(
20
20
  :endpoint => base_url,
21
21
  :consumer_key => @rcfile.default_consumer_key,
@@ -26,12 +26,14 @@ module T
26
26
  end
27
27
 
28
28
  def host
29
- parent_options['host'] || DEFAULT_HOST
29
+ options['host'] || DEFAULT_HOST
30
30
  end
31
31
 
32
32
  def protocol
33
- parent_options['no_ssl'] ? 'http' : DEFAULT_PROTOCOL
33
+ options['no_ssl'] ? 'http' : DEFAULT_PROTOCOL
34
34
  end
35
+
35
36
  end
37
+
36
38
  end
37
39
  end
@@ -1,6 +1,7 @@
1
1
  require 'action_view'
2
2
  require 'retryable'
3
3
  require 't/core_ext/enumerable'
4
+ require 't/printable'
4
5
  require 't/rcfile'
5
6
  require 't/requestable'
6
7
  require 'thor'
@@ -8,6 +9,7 @@ require 'thor'
8
9
  module T
9
10
  class Search < Thor
10
11
  include ActionView::Helpers::DateHelper
12
+ include T::Printable
11
13
  include T::Requestable
12
14
 
13
15
  DEFAULT_NUM_RESULTS = 20
@@ -27,14 +29,14 @@ module T
27
29
  def all(query)
28
30
  rpp = options['number'] || DEFAULT_NUM_RESULTS
29
31
  statuses = client.search(query, :include_entities => false, :rpp => rpp)
30
- if parent_options['long']
32
+ if options['long']
31
33
  array = statuses.map do |status|
32
34
  created_at = status.created_at > 6.months.ago ? status.created_at.strftime("%b %e %H:%M") : status.created_at.strftime("%b %e %Y")
33
35
  [status.id.to_s, created_at, status.from_user, status.text.gsub(/\n+/, ' ')]
34
36
  end
35
37
  if STDOUT.tty?
36
- headings = ["ID", "Created at", "Screen name", "Text"]
37
- array.unshift(headings)
38
+ headings = ["ID", "Posted at", "Screen name", "Text"]
39
+ array.unshift(headings) unless statuses.empty?
38
40
  end
39
41
  print_table(array)
40
42
  else
@@ -98,7 +100,7 @@ module T
98
100
 
99
101
  desc "user SCREEN_NAME QUERY", "Returns Tweets in a user's timeline that match a specified query."
100
102
  def user(screen_name, query)
101
- screen_name = screen_name.strip_at
103
+ screen_name = screen_name.strip_ats
102
104
  statuses = 1.upto(MAX_PAGES).threaded_map do |page|
103
105
  retryable(:tries => 3, :on => Twitter::Error::ServerError, :sleep => 0) do
104
106
  client.user_timeline(screen_name, :page => page, :count => MAX_NUM_RESULTS).select do |status|
@@ -109,25 +111,5 @@ module T
109
111
  print_status_list(statuses)
110
112
  end
111
113
 
112
- private
113
-
114
- def print_status_list(statuses)
115
- if parent_options['long']
116
- array = statuses.map do |status|
117
- created_at = status.created_at > 6.months.ago ? status.created_at.strftime("%b %e %H:%M") : status.created_at.strftime("%b %e %Y")
118
- [status.id.to_s, created_at, status.user.screen_name, status.text.gsub(/\n+/, ' ')]
119
- end
120
- if STDOUT.tty?
121
- headings = ["ID", "Created at", "Screen name", "Text"]
122
- array.unshift(headings)
123
- end
124
- print_table(array)
125
- else
126
- statuses.each do |status|
127
- say "#{status.user.screen_name.rjust(MAX_SCREEN_NAME_SIZE)}: #{status.text.gsub(/\n+/, ' ')} (#{time_ago_in_words(status.created_at)} ago)"
128
- end
129
- end
130
- end
131
-
132
114
  end
133
115
  end
@@ -22,8 +22,8 @@ module T
22
22
 
23
23
  desc "default SCREEN_NAME [CONSUMER_KEY]", "Set your default account."
24
24
  def default(screen_name, consumer_key=nil)
25
- screen_name = screen_name.strip_at
26
- @rcfile.path = parent_options['profile'] if parent_options['profile']
25
+ screen_name = screen_name.strip_ats
26
+ @rcfile.path = options['profile'] if options['profile']
27
27
  consumer_key = @rcfile[screen_name].keys.last if consumer_key.nil?
28
28
  @rcfile.default_profile = {'username' => screen_name, 'consumer_key' => consumer_key}
29
29
  say "Default account has been updated."
@@ -8,12 +8,12 @@ module T
8
8
 
9
9
  # @return [Integer]
10
10
  def self.minor
11
- 5
11
+ 6
12
12
  end
13
13
 
14
14
  # @return [Integer]
15
15
  def self.patch
16
- 1
16
+ 0
17
17
  end
18
18
 
19
19
  # @return [String, NilClass]
@@ -6,12 +6,12 @@ describe T::CLI do
6
6
  before do
7
7
  rcfile = RCFile.instance
8
8
  rcfile.path = fixture_path + "/.trc"
9
- @t = T::CLI.new
9
+ @cli = T::CLI.new
10
10
  @old_stderr = $stderr
11
11
  $stderr = StringIO.new
12
12
  @old_stdout = $stdout
13
13
  $stdout = StringIO.new
14
- Timecop.freeze(Time.local(2011, 11, 24, 16, 20, 0))
14
+ Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
15
15
  end
16
16
 
17
17
  after do
@@ -22,20 +22,20 @@ describe T::CLI do
22
22
 
23
23
  describe "#account" do
24
24
  before do
25
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
25
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
26
26
  end
27
27
  it "should have the correct output" do
28
- @t.accounts
29
- $stdout.string.should == <<-eos.gsub(/^ {8}/, '')
30
- testcli
31
- abc123 (default)
28
+ @cli.accounts
29
+ $stdout.string.should == <<-eos
30
+ testcli
31
+ abc123 (default)
32
32
  eos
33
33
  end
34
34
  end
35
35
 
36
36
  describe "#authorize" do
37
37
  before do
38
- @t.options = @t.options.merge(:profile => File.expand_path('/tmp/trc', __FILE__), :consumer_key => "abc123", :consumer_secret => "asdfasd223sd2", :prompt => true, :dry_run => true)
38
+ @cli.options = @cli.options.merge(:profile => File.expand_path('/tmp/trc', __FILE__), :consumer_key => "abc123", :consumer_secret => "asdfasd223sd2", :prompt => true, :dry_run => true)
39
39
  stub_post("/oauth/request_token").
40
40
  to_return(:body => fixture("request_token"))
41
41
  stub_post("/oauth/access_token").
@@ -48,7 +48,7 @@ describe T::CLI do
48
48
  $stdin.should_receive(:gets).and_return("\n")
49
49
  $stdout.should_receive(:print).with("Paste in the supplied PIN: ")
50
50
  $stdin.should_receive(:gets).and_return("1234567890")
51
- @t.authorize
51
+ @cli.authorize
52
52
  a_post("/oauth/request_token").
53
53
  should have_been_made
54
54
  a_post("/oauth/access_token").
@@ -62,26 +62,26 @@ describe T::CLI do
62
62
  $stdin.should_receive(:gets).and_return("\n")
63
63
  $stdout.should_receive(:print).with("Paste in the supplied PIN: ")
64
64
  $stdin.should_receive(:gets).and_return("1234567890")
65
- @t.authorize
65
+ @cli.authorize
66
66
  end.should_not raise_error
67
67
  end
68
68
  end
69
69
 
70
70
  describe "#block" do
71
71
  before do
72
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
72
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
73
73
  stub_post("/1/blocks/create.json").
74
74
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
75
75
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
76
76
  end
77
77
  it "should request the correct resource" do
78
- @t.block("sferik")
78
+ @cli.block("sferik")
79
79
  a_post("/1/blocks/create.json").
80
80
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
81
81
  should have_been_made
82
82
  end
83
83
  it "should have the correct output" do
84
- @t.block("sferik")
84
+ @cli.block("sferik")
85
85
  $stdout.string.should =~ /^@testcli blocked @sferik/
86
86
  end
87
87
  end
@@ -93,36 +93,81 @@ describe T::CLI do
93
93
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
94
94
  end
95
95
  it "should request the correct resource" do
96
- @t.direct_messages
96
+ @cli.direct_messages
97
97
  a_get("/1/direct_messages.json").
98
98
  with(:query => {:count => "20", :include_entities => "false"}).
99
99
  should have_been_made
100
100
  end
101
101
  it "should have the correct output" do
102
- @t.direct_messages
103
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
104
- sferik: Sounds good. Meeting Tuesday is fine. (about 1 year ago)
105
- sferik: if you want to add me to your GroupMe group, my phone number is 415-312-2382 (about 1 year ago)
106
- sferik: That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you? (about 1 year ago)
107
- sferik: I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better. (about 1 year ago)
108
- sferik: Just checking in. How's everything going? (about 1 year ago)
109
- sferik: Any luck completing graphs this weekend? There have been lots of commits to RailsAdmin since summer ended but none from you. How's it going? (about 1 year ago)
110
- sferik: Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend? (about 1 year ago)
111
- sferik: Looks good to me. I'm going to pull in the change now. My only concern is that we don't have any tests for auth. (about 1 year ago)
112
- sferik: How are the graph enhancements coming? (about 1 year ago)
113
- sferik: Changes pushed. You should pull and re-bundle when you have a minute. (about 1 year ago)
114
- sferik: Glad to hear the new graphs are coming along. Can't wait to see them! (about 1 year ago)
115
- sferik: I figured out what was wrong with the tests: I accidentally unbundled webrat. The problem had nothing to do with rspec-rails. (about 1 year ago)
116
- sferik: After the upgrade 54/80 specs are failing. I'm working on fixing them now. (about 1 year ago)
117
- sferik: a new version of rspec-rails just shipped with some nice features and fixes http://github.com/rspec/rspec-rails/blob/master/History.md (about 1 year ago)
118
- sferik: How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël. (about 1 year ago)
119
- sferik: Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final? (about 1 year ago)
120
- sferik: I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts. (about 1 year ago)
121
- sferik: Can you try upgrading to 1.9.2 final, re-installing Bundler 1.0.0.rc.6 (don't remove 1.0.0) and see if you can reproduce the problem? (about 1 year ago)
122
- sferik: I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running? (about 1 year ago)
123
- sferik: Let's try to debug that problem during our session in 1.5 hours. In the mean time, try working on the graphs or internationalization. (about 1 year ago)
102
+ @cli.direct_messages
103
+ $stdout.string.should == <<-eos
104
+ sferik: Sounds good. Meeting Tuesday is fine. (about 1 year ago)
105
+ sferik: That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you? (about 1 year ago)
106
+ sferik: I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better. (about 1 year ago)
107
+ sferik: Just checking in. How's everything going? (about 1 year ago)
108
+ sferik: Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend? (about 1 year ago)
109
+ sferik: How are the graph enhancements coming? (about 1 year ago)
110
+ sferik: How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël. (about 1 year ago)
111
+ sferik: Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final? (about 1 year ago)
112
+ sferik: I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts. (about 1 year ago)
113
+ sferik: I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running? (about 1 year ago)
124
114
  eos
125
115
  end
116
+ context "--long" do
117
+ before do
118
+ @cli.options = @cli.options.merge(:long => true)
119
+ end
120
+ it "should list in long format" do
121
+ @cli.direct_messages
122
+ $stdout.string.should == <<-eos
123
+ ID Posted at Screen name Text
124
+ 1,773,478,249 Oct 17 2010 sferik Sounds good. Meeting Tuesday is fine.
125
+ 1,762,960,771 Oct 14 2010 sferik That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you?
126
+ 1,711,812,216 Oct 1 2010 sferik I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better.
127
+ 1,711,417,617 Oct 1 2010 sferik Just checking in. How's everything going?
128
+ 1,653,301,471 Sep 16 2010 sferik Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend?
129
+ 1,645,324,992 Sep 14 2010 sferik How are the graph enhancements coming?
130
+ 1,632,933,616 Sep 11 2010 sferik How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël.
131
+ 1,629,239,903 Sep 10 2010 sferik Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
132
+ 1,629,166,212 Sep 10 2010 sferik I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts.
133
+ 1,624,782,206 Sep 9 2010 sferik I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running?
134
+ eos
135
+ end
136
+ end
137
+ context "--number" do
138
+ before do
139
+ @cli.options = @cli.options.merge(:number => 1)
140
+ stub_get("/1/direct_messages.json").
141
+ with(:query => {:count => "1", :include_entities => "false"}).
142
+ to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
143
+ end
144
+ it "should limit the number of results" do
145
+ @cli.direct_messages
146
+ a_get("/1/direct_messages.json").
147
+ with(:query => {:count => "1", :include_entities => "false"}).
148
+ should have_been_made
149
+ end
150
+ end
151
+ context "--reverse" do
152
+ before do
153
+ @cli.options = @cli.options.merge(:reverse => true)
154
+ end
155
+ it "should reverse the order of the sort" do
156
+ @cli.direct_messages
157
+ $stdout.string.should == <<-eos
158
+ sferik: I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running? (about 1 year ago)
159
+ sferik: I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts. (about 1 year ago)
160
+ sferik: Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final? (about 1 year ago)
161
+ sferik: How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël. (about 1 year ago)
162
+ sferik: How are the graph enhancements coming? (about 1 year ago)
163
+ sferik: Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend? (about 1 year ago)
164
+ sferik: Just checking in. How's everything going? (about 1 year ago)
165
+ sferik: I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better. (about 1 year ago)
166
+ sferik: That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you? (about 1 year ago)
167
+ sferik: Sounds good. Meeting Tuesday is fine. (about 1 year ago)
168
+ eos
169
+ end
170
+ end
126
171
  end
127
172
 
128
173
  describe "#direct_messages_sent" do
@@ -132,70 +177,115 @@ describe T::CLI do
132
177
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
133
178
  end
134
179
  it "should request the correct resource" do
135
- @t.direct_messages_sent
180
+ @cli.direct_messages_sent
136
181
  a_get("/1/direct_messages/sent.json").
137
182
  with(:query => {:count => "20", :include_entities => "false"}).
138
183
  should have_been_made
139
184
  end
140
185
  it "should have the correct output" do
141
- @t.direct_messages_sent
142
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 3)
143
- hurrycane: Sounds good. Meeting Tuesday is fine. (about 1 year ago)
144
- technoweenie: if you want to add me to your GroupMe group, my phone number is 415-312-2382 (about 1 year ago)
145
- hurrycane: That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you? (about 1 year ago)
146
- hurrycane: I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better. (about 1 year ago)
147
- hurrycane: Just checking in. How's everything going? (about 1 year ago)
148
- hurrycane: Any luck completing graphs this weekend? There have been lots of commits to RailsAdmin since summer ended but none from you. How's it going? (about 1 year ago)
149
- hurrycane: Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend? (about 1 year ago)
150
- hurrycane: Looks good to me. I'm going to pull in the change now. My only concern is that we don't have any tests for auth. (about 1 year ago)
151
- hurrycane: How are the graph enhancements coming? (about 1 year ago)
152
- hurrycane: Changes pushed. You should pull and re-bundle when you have a minute. (about 1 year ago)
153
- hurrycane: Glad to hear the new graphs are coming along. Can't wait to see them! (about 1 year ago)
154
- hurrycane: I figured out what was wrong with the tests: I accidentally unbundled webrat. The problem had nothing to do with rspec-rails. (about 1 year ago)
155
- hurrycane: After the upgrade 54/80 specs are failing. I'm working on fixing them now. (about 1 year ago)
156
- hurrycane: a new version of rspec-rails just shipped with some nice features and fixes http://github.com/rspec/rspec-rails/blob/master/History.md (about 1 year ago)
157
- hurrycane: How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël. (about 1 year ago)
158
- hurrycane: Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final? (about 1 year ago)
159
- hurrycane: I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts. (about 1 year ago)
160
- hurrycane: Can you try upgrading to 1.9.2 final, re-installing Bundler 1.0.0.rc.6 (don't remove 1.0.0) and see if you can reproduce the problem? (about 1 year ago)
161
- hurrycane: I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running? (about 1 year ago)
162
- hurrycane: Let's try to debug that problem during our session in 1.5 hours. In the mean time, try working on the graphs or internationalization. (about 1 year ago)
186
+ @cli.direct_messages_sent
187
+ $stdout.string.should == <<-eos
188
+ hurrycane: Sounds good. Meeting Tuesday is fine. (about 1 year ago)
189
+ hurrycane: That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you? (about 1 year ago)
190
+ hurrycane: I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better. (about 1 year ago)
191
+ hurrycane: Just checking in. How's everything going? (about 1 year ago)
192
+ hurrycane: Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend? (about 1 year ago)
193
+ hurrycane: How are the graph enhancements coming? (about 1 year ago)
194
+ hurrycane: How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël. (about 1 year ago)
195
+ hurrycane: Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final? (about 1 year ago)
196
+ hurrycane: I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts. (about 1 year ago)
197
+ hurrycane: I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running? (about 1 year ago)
163
198
  eos
164
199
  end
200
+ context "--long" do
201
+ before do
202
+ @cli.options = @cli.options.merge(:long => true)
203
+ end
204
+ it "should list in long format" do
205
+ @cli.direct_messages_sent
206
+ $stdout.string.should == <<-eos
207
+ ID Posted at Screen name Text
208
+ 1,773,478,249 Oct 17 2010 hurrycane Sounds good. Meeting Tuesday is fine.
209
+ 1,762,960,771 Oct 14 2010 hurrycane That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you?
210
+ 1,711,812,216 Oct 1 2010 hurrycane I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better.
211
+ 1,711,417,617 Oct 1 2010 hurrycane Just checking in. How's everything going?
212
+ 1,653,301,471 Sep 16 2010 hurrycane Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend?
213
+ 1,645,324,992 Sep 14 2010 hurrycane How are the graph enhancements coming?
214
+ 1,632,933,616 Sep 11 2010 hurrycane How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël.
215
+ 1,629,239,903 Sep 10 2010 hurrycane Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
216
+ 1,629,166,212 Sep 10 2010 hurrycane I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts.
217
+ 1,624,782,206 Sep 9 2010 hurrycane I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running?
218
+ eos
219
+ end
220
+ end
221
+ context "--number" do
222
+ before do
223
+ @cli.options = @cli.options.merge(:number => 1)
224
+ stub_get("/1/direct_messages/sent.json").
225
+ with(:query => {:count => "1", :include_entities => "false"}).
226
+ to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
227
+ end
228
+ it "should limit the number of results" do
229
+ @cli.direct_messages_sent
230
+ a_get("/1/direct_messages/sent.json").
231
+ with(:query => {:count => "1", :include_entities => "false"}).
232
+ should have_been_made
233
+ end
234
+ end
235
+ context "--reverse" do
236
+ before do
237
+ @cli.options = @cli.options.merge(:reverse => true)
238
+ end
239
+ it "should reverse the order of the sort" do
240
+ @cli.direct_messages_sent
241
+ $stdout.string.should == <<-eos
242
+ hurrycane: I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running? (about 1 year ago)
243
+ hurrycane: I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts. (about 1 year ago)
244
+ hurrycane: Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final? (about 1 year ago)
245
+ hurrycane: How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël. (about 1 year ago)
246
+ hurrycane: How are the graph enhancements coming? (about 1 year ago)
247
+ hurrycane: Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend? (about 1 year ago)
248
+ hurrycane: Just checking in. How's everything going? (about 1 year ago)
249
+ hurrycane: I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better. (about 1 year ago)
250
+ hurrycane: That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you? (about 1 year ago)
251
+ hurrycane: Sounds good. Meeting Tuesday is fine. (about 1 year ago)
252
+ eos
253
+ end
254
+ end
165
255
  end
166
256
 
167
257
  describe "#dm" do
168
258
  before do
169
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
259
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
170
260
  stub_post("/1/direct_messages/new.json").
171
261
  with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
172
262
  to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
173
263
  end
174
264
  it "should request the correct resource" do
175
- @t.dm("pengwynn", "Creating a fixture for the Twitter gem")
265
+ @cli.dm("pengwynn", "Creating a fixture for the Twitter gem")
176
266
  a_post("/1/direct_messages/new.json").
177
267
  with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
178
268
  should have_been_made
179
269
  end
180
270
  it "should have the correct output" do
181
- @t.dm("pengwynn", "Creating a fixture for the Twitter gem")
271
+ @cli.dm("pengwynn", "Creating a fixture for the Twitter gem")
182
272
  $stdout.string.chomp.should == "Direct Message sent from @testcli to @pengwynn (about 1 year ago)."
183
273
  end
184
274
  end
185
275
 
186
276
  describe "#favorite" do
187
277
  before do
188
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
278
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
189
279
  stub_post("/1/favorites/create/26755176471724032.json").
190
280
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
191
281
  end
192
282
  it "should request the correct resource" do
193
- @t.favorite("26755176471724032")
283
+ @cli.favorite("26755176471724032")
194
284
  a_post("/1/favorites/create/26755176471724032.json").
195
285
  should have_been_made
196
286
  end
197
287
  it "should have the correct output" do
198
- @t.favorite("26755176471724032")
288
+ @cli.favorite("26755176471724032")
199
289
  $stdout.string.should =~ /^@testcli favorited @sferik's status: "@noradio working on implementing #NewTwitter API methods in the twitter gem\. Twurl is making it easy\. Thank you!"$/
200
290
  end
201
291
  end
@@ -207,45 +297,112 @@ describe T::CLI do
207
297
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
208
298
  end
209
299
  it "should request the correct resource" do
210
- @t.favorites
300
+ @cli.favorites
211
301
  a_get("/1/favorites.json").
212
302
  with(:query => {:count => "20", :include_entities => "false"}).
213
303
  should have_been_made
214
304
  end
215
305
  it "should have the correct output" do
216
- @t.favorites
217
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
218
- sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
219
- sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
220
- sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
221
- sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
222
- sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
223
- sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
224
- sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
225
- sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
226
- sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
227
- sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
228
- sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
229
- sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
230
- sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
231
- sferik: Ping: kills MySpace dead. (about 1 year ago)
232
- sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
233
- sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
234
- sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
235
- sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
236
- sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
306
+ @cli.favorites
307
+ $stdout.string.should == <<-eos
308
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
309
+ TD: @kelseysilver how long will you be in town? (7 months ago)
310
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
311
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
312
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
313
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
314
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
315
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
316
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
317
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
318
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
319
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
320
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
321
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
322
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
323
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
324
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
237
325
  eos
238
326
  end
327
+ context "--long" do
328
+ before do
329
+ @cli.options = @cli.options.merge(:long => true)
330
+ end
331
+ it "should list in long format" do
332
+ @cli.favorites
333
+ $stdout.string.should == <<-eos
334
+ ID Posted at Screen name Text
335
+ 194,548,121,416,630,272 Apr 23 2011 natevillegas RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present.
336
+ 194,547,993,607,806,976 Apr 23 2011 TD @kelseysilver how long will you be in town?
337
+ 194,547,987,593,183,233 Apr 23 2011 rusashka @maciej hahaha :) @gpena together we're going to cover all core 28 languages!
338
+ 194,547,824,690,597,888 Apr 23 2011 fat @stevej @xc i'm going to picket when i get back.
339
+ 194,547,658,562,605,057 Apr 23 2011 wil @0x9900 @paulnivin http://t.co/bwVdtAPe
340
+ 194,547,528,430,137,344 Apr 23 2011 wangtian @tianhonghe @xiangxin72 oh, you can even order specific items?
341
+ 194,547,402,550,689,793 Apr 23 2011 shinypb @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird
342
+ 194,547,260,233,760,768 Apr 23 2011 0x9900 @wil @paulnivin if you want to take you seriously don't say daemontools!
343
+ 194,547,084,349,804,544 Apr 23 2011 kpk @shinypb @skilldrick @hoverbird invented it
344
+ 194,546,876,782,092,291 Apr 23 2011 skilldrick @shinypb Well played :) @hoverbird
345
+ 194,546,811,480,969,217 Apr 23 2011 sam Can someone project the date that I'll get a 27" retina display?
346
+ 194,546,738,810,458,112 Apr 23 2011 shinypb @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain.
347
+ 194,546,727,670,390,784 Apr 23 2011 bartt @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come.
348
+ 194,546,649,203,347,456 Apr 23 2011 skilldrick @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all.
349
+ 194,546,583,608,639,488 Apr 23 2011 sean @mep Thanks for coming by. Was great to have you.
350
+ 194,546,388,707,717,120 Apr 23 2011 hoverbird @shinypb @trammell it's all suck a "duck blur" sometimes.
351
+ 194,546,264,212,385,793 Apr 23 2011 kelseysilver San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw
352
+ eos
353
+ end
354
+ end
355
+ context "--number" do
356
+ before do
357
+ @cli.options = @cli.options.merge(:number => 1)
358
+ stub_get("/1/favorites.json").
359
+ with(:query => {:count => "1", :include_entities => "false"}).
360
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
361
+ end
362
+ it "should limit the number of results" do
363
+ @cli.favorites
364
+ a_get("/1/favorites.json").
365
+ with(:query => {:count => "1", :include_entities => "false"}).
366
+ should have_been_made
367
+ end
368
+ end
369
+ context "--reverse" do
370
+ before do
371
+ @cli.options = @cli.options.merge(:reverse => true)
372
+ end
373
+ it "should reverse the order of the sort" do
374
+ @cli.favorites
375
+ $stdout.string.should == <<-eos
376
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
377
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
378
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
379
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
380
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
381
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
382
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
383
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
384
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
385
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
386
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
387
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
388
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
389
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
390
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
391
+ TD: @kelseysilver how long will you be in town? (7 months ago)
392
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
393
+ eos
394
+ end
395
+ end
239
396
  end
240
397
 
241
398
  describe "#follow" do
242
399
  before do
243
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
400
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
244
401
  end
245
402
  context "no users" do
246
403
  it "should exit" do
247
404
  lambda do
248
- @t.follow
405
+ @cli.follow
249
406
  end.should raise_error
250
407
  end
251
408
  end
@@ -254,7 +411,7 @@ describe T::CLI do
254
411
  stub_post("/1/friendships/create.json").
255
412
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
256
413
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
257
- @t.follow("sferik")
414
+ @cli.follow("sferik")
258
415
  a_post("/1/friendships/create.json").
259
416
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
260
417
  should have_been_made
@@ -263,7 +420,7 @@ describe T::CLI do
263
420
  stub_post("/1/friendships/create.json").
264
421
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
265
422
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
266
- @t.follow("sferik")
423
+ @cli.follow("sferik")
267
424
  $stdout.string.should =~ /^@testcli is now following 1 more user\.$/
268
425
  end
269
426
  context "Twitter is down" do
@@ -272,7 +429,7 @@ describe T::CLI do
272
429
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
273
430
  to_return(:status => 502)
274
431
  lambda do
275
- @t.follow("sferik")
432
+ @cli.follow("sferik")
276
433
  end.should raise_error("Twitter is down or being upgraded.")
277
434
  a_post("/1/friendships/create.json").
278
435
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
@@ -292,7 +449,7 @@ describe T::CLI do
292
449
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
293
450
  end
294
451
  it "should request the correct resource" do
295
- @t.followings
452
+ @cli.followings
296
453
  a_get("/1/friends/ids.json").
297
454
  with(:query => {:cursor => "-1"}).
298
455
  should have_been_made
@@ -301,9 +458,85 @@ describe T::CLI do
301
458
  should have_been_made
302
459
  end
303
460
  it "should have the correct output" do
304
- @t.followings
461
+ @cli.followings
305
462
  $stdout.string.chomp.rstrip.should == "pengwynn sferik"
306
463
  end
464
+ context "--created" do
465
+ before do
466
+ @cli.options = @cli.options.merge(:created => true)
467
+ end
468
+ it "should sort by the time when Twitter acount was created" do
469
+ @cli.followings
470
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
471
+ end
472
+ end
473
+ context "--favorites" do
474
+ before do
475
+ @cli.options = @cli.options.merge(:favorites => true)
476
+ end
477
+ it "should sort by number of favorites" do
478
+ @cli.followings
479
+ $stdout.string.chomp.rstrip.should == "pengwynn sferik"
480
+ end
481
+ end
482
+ context "--followers" do
483
+ before do
484
+ @cli.options = @cli.options.merge(:followers => true)
485
+ end
486
+ it "should sort by number of followers" do
487
+ @cli.followings
488
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
489
+ end
490
+ end
491
+ context "--friends" do
492
+ before do
493
+ @cli.options = @cli.options.merge(:friends => true)
494
+ end
495
+ it "should sort by number of friends" do
496
+ @cli.followings
497
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
498
+ end
499
+ end
500
+ context "--listed" do
501
+ before do
502
+ @cli.options = @cli.options.merge(:listed => true)
503
+ end
504
+ it "should sort by number of list memberships" do
505
+ @cli.followings
506
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
507
+ end
508
+ end
509
+ context "--long" do
510
+ before do
511
+ @cli.options = @cli.options.merge(:long => true)
512
+ end
513
+ it "should list in long format" do
514
+ @cli.followings
515
+ $stdout.string.should == <<-eos
516
+ ID Since Tweets Favorites Listed Following Followers Screen name Name
517
+ 14,100,886 Mar 8 2008 3,913 32 185 1,871 2,767 pengwynn Wynn Netherland
518
+ 7,505,382 Jul 16 2007 2,962 727 29 88 898 sferik Erik Michaels-Ober
519
+ eos
520
+ end
521
+ end
522
+ context "--reverse" do
523
+ before do
524
+ @cli.options = @cli.options.merge(:reverse => true)
525
+ end
526
+ it "should reverse the order of the sort" do
527
+ @cli.followings
528
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
529
+ end
530
+ end
531
+ context "--tweets" do
532
+ before do
533
+ @cli.options = @cli.options.merge(:tweets => true)
534
+ end
535
+ it "should sort by number of Tweets" do
536
+ @cli.followings
537
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
538
+ end
539
+ end
307
540
  end
308
541
 
309
542
  describe "#followers" do
@@ -316,7 +549,7 @@ describe T::CLI do
316
549
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
317
550
  end
318
551
  it "should request the correct resource" do
319
- @t.followers
552
+ @cli.followers
320
553
  a_get("/1/followers/ids.json").
321
554
  with(:query => {:cursor => "-1"}).
322
555
  should have_been_made
@@ -325,9 +558,85 @@ describe T::CLI do
325
558
  should have_been_made
326
559
  end
327
560
  it "should have the correct output" do
328
- @t.followers
561
+ @cli.followers
329
562
  $stdout.string.chomp.rstrip.should == "pengwynn sferik"
330
563
  end
564
+ context "--created" do
565
+ before do
566
+ @cli.options = @cli.options.merge(:created => true)
567
+ end
568
+ it "should sort by the time when Twitter acount was created" do
569
+ @cli.followers
570
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
571
+ end
572
+ end
573
+ context "--favorites" do
574
+ before do
575
+ @cli.options = @cli.options.merge(:favorites => true)
576
+ end
577
+ it "should sort by number of favorites" do
578
+ @cli.followers
579
+ $stdout.string.chomp.rstrip.should == "pengwynn sferik"
580
+ end
581
+ end
582
+ context "--followers" do
583
+ before do
584
+ @cli.options = @cli.options.merge(:followers => true)
585
+ end
586
+ it "should sort by number of followers" do
587
+ @cli.followers
588
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
589
+ end
590
+ end
591
+ context "--friends" do
592
+ before do
593
+ @cli.options = @cli.options.merge(:friends => true)
594
+ end
595
+ it "should sort by number of friends" do
596
+ @cli.followers
597
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
598
+ end
599
+ end
600
+ context "--listed" do
601
+ before do
602
+ @cli.options = @cli.options.merge(:listed => true)
603
+ end
604
+ it "should sort by number of list memberships" do
605
+ @cli.followers
606
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
607
+ end
608
+ end
609
+ context "--long" do
610
+ before do
611
+ @cli.options = @cli.options.merge(:long => true)
612
+ end
613
+ it "should list in long format" do
614
+ @cli.followers
615
+ $stdout.string.should == <<-eos
616
+ ID Since Tweets Favorites Listed Following Followers Screen name Name
617
+ 14,100,886 Mar 8 2008 3,913 32 185 1,871 2,767 pengwynn Wynn Netherland
618
+ 7,505,382 Jul 16 2007 2,962 727 29 88 898 sferik Erik Michaels-Ober
619
+ eos
620
+ end
621
+ end
622
+ context "--reverse" do
623
+ before do
624
+ @cli.options = @cli.options.merge(:reverse => true)
625
+ end
626
+ it "should reverse the order of the sort" do
627
+ @cli.followers
628
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
629
+ end
630
+ end
631
+ context "--tweets" do
632
+ before do
633
+ @cli.options = @cli.options.merge(:tweets => true)
634
+ end
635
+ it "should sort by number of Tweets" do
636
+ @cli.followers
637
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
638
+ end
639
+ end
331
640
  end
332
641
 
333
642
  describe "#friends" do
@@ -343,7 +652,7 @@ describe T::CLI do
343
652
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
344
653
  end
345
654
  it "should request the correct resource" do
346
- @t.friends
655
+ @cli.friends
347
656
  a_get("/1/friends/ids.json").
348
657
  with(:query => {:cursor => "-1"}).
349
658
  should have_been_made
@@ -355,9 +664,85 @@ describe T::CLI do
355
664
  should have_been_made
356
665
  end
357
666
  it "should have the correct output" do
358
- @t.friends
667
+ @cli.friends
359
668
  $stdout.string.chomp.rstrip.should == "pengwynn sferik"
360
669
  end
670
+ context "--created" do
671
+ before do
672
+ @cli.options = @cli.options.merge(:created => true)
673
+ end
674
+ it "should sort by the time when Twitter acount was created" do
675
+ @cli.friends
676
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
677
+ end
678
+ end
679
+ context "--favorites" do
680
+ before do
681
+ @cli.options = @cli.options.merge(:favorites => true)
682
+ end
683
+ it "should sort by number of favorites" do
684
+ @cli.friends
685
+ $stdout.string.chomp.rstrip.should == "pengwynn sferik"
686
+ end
687
+ end
688
+ context "--followers" do
689
+ before do
690
+ @cli.options = @cli.options.merge(:followers => true)
691
+ end
692
+ it "should sort by number of followers" do
693
+ @cli.friends
694
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
695
+ end
696
+ end
697
+ context "--friends" do
698
+ before do
699
+ @cli.options = @cli.options.merge(:friends => true)
700
+ end
701
+ it "should sort by number of friends" do
702
+ @cli.friends
703
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
704
+ end
705
+ end
706
+ context "--listed" do
707
+ before do
708
+ @cli.options = @cli.options.merge(:listed => true)
709
+ end
710
+ it "should sort by number of list memberships" do
711
+ @cli.friends
712
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
713
+ end
714
+ end
715
+ context "--long" do
716
+ before do
717
+ @cli.options = @cli.options.merge(:long => true)
718
+ end
719
+ it "should list in long format" do
720
+ @cli.friends
721
+ $stdout.string.should == <<-eos
722
+ ID Since Tweets Favorites Listed Following Followers Screen name Name
723
+ 14,100,886 Mar 8 2008 3,913 32 185 1,871 2,767 pengwynn Wynn Netherland
724
+ 7,505,382 Jul 16 2007 2,962 727 29 88 898 sferik Erik Michaels-Ober
725
+ eos
726
+ end
727
+ end
728
+ context "--reverse" do
729
+ before do
730
+ @cli.options = @cli.options.merge(:reverse => true)
731
+ end
732
+ it "should reverse the order of the sort" do
733
+ @cli.friends
734
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
735
+ end
736
+ end
737
+ context "--tweets" do
738
+ before do
739
+ @cli.options = @cli.options.merge(:tweets => true)
740
+ end
741
+ it "should sort by number of Tweets" do
742
+ @cli.friends
743
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
744
+ end
745
+ end
361
746
  end
362
747
 
363
748
  describe "#leaders" do
@@ -367,38 +752,102 @@ describe T::CLI do
367
752
  to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
368
753
  stub_get("/1/followers/ids.json").
369
754
  with(:query => {:cursor => "-1"}).
370
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
755
+ to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
756
+ stub_get("/1/users/lookup.json").
757
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
758
+ to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
371
759
  end
372
760
  it "should request the correct resource" do
373
- @t.leaders
761
+ @cli.leaders
374
762
  a_get("/1/friends/ids.json").
375
763
  with(:query => {:cursor => "-1"}).
376
764
  should have_been_made
377
765
  a_get("/1/followers/ids.json").
378
766
  with(:query => {:cursor => "-1"}).
379
767
  should have_been_made
768
+ a_get("/1/users/lookup.json").
769
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
770
+ should have_been_made
380
771
  end
381
772
  it "should have the correct output" do
382
- @t.leaders
383
- $stdout.string.chomp.rstrip.should == ""
773
+ @cli.leaders
774
+ $stdout.string.chomp.rstrip.should == "pengwynn sferik"
384
775
  end
385
- end
386
-
387
- describe "#members" do
388
- before do
389
- stub_get("/1/lists/members.json").
390
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
391
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
776
+ context "--created" do
777
+ before do
778
+ @cli.options = @cli.options.merge(:created => true)
779
+ end
780
+ it "should sort by the time when Twitter acount was created" do
781
+ @cli.leaders
782
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
783
+ end
392
784
  end
393
- it "should request the correct resource" do
394
- @t.members("sferik", "presidents")
395
- a_get("/1/lists/members.json").
396
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
397
- should have_been_made
785
+ context "--favorites" do
786
+ before do
787
+ @cli.options = @cli.options.merge(:favorites => true)
788
+ end
789
+ it "should sort by number of favorites" do
790
+ @cli.leaders
791
+ $stdout.string.chomp.rstrip.should == "pengwynn sferik"
792
+ end
398
793
  end
399
- it "should have the correct output" do
400
- @t.members("sferik", "presidents")
401
- $stdout.string.chomp.should == ""
794
+ context "--followers" do
795
+ before do
796
+ @cli.options = @cli.options.merge(:followers => true)
797
+ end
798
+ it "should sort by number of followers" do
799
+ @cli.leaders
800
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
801
+ end
802
+ end
803
+ context "--friends" do
804
+ before do
805
+ @cli.options = @cli.options.merge(:friends => true)
806
+ end
807
+ it "should sort by number of friends" do
808
+ @cli.leaders
809
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
810
+ end
811
+ end
812
+ context "--listed" do
813
+ before do
814
+ @cli.options = @cli.options.merge(:listed => true)
815
+ end
816
+ it "should sort by number of list memberships" do
817
+ @cli.leaders
818
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
819
+ end
820
+ end
821
+ context "--long" do
822
+ before do
823
+ @cli.options = @cli.options.merge(:long => true)
824
+ end
825
+ it "should list in long format" do
826
+ @cli.leaders
827
+ $stdout.string.should == <<-eos
828
+ ID Since Tweets Favorites Listed Following Followers Screen name Name
829
+ 14,100,886 Mar 8 2008 3,913 32 185 1,871 2,767 pengwynn Wynn Netherland
830
+ 7,505,382 Jul 16 2007 2,962 727 29 88 898 sferik Erik Michaels-Ober
831
+ eos
832
+ end
833
+ end
834
+ context "--reverse" do
835
+ before do
836
+ @cli.options = @cli.options.merge(:reverse => true)
837
+ end
838
+ it "should reverse the order of the sort" do
839
+ @cli.leaders
840
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
841
+ end
842
+ end
843
+ context "--tweets" do
844
+ before do
845
+ @cli.options = @cli.options.merge(:tweets => true)
846
+ end
847
+ it "should sort by number of Tweets" do
848
+ @cli.leaders
849
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
850
+ end
402
851
  end
403
852
  end
404
853
 
@@ -409,51 +858,118 @@ describe T::CLI do
409
858
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
410
859
  end
411
860
  it "should request the correct resource" do
412
- @t.mentions
861
+ @cli.mentions
413
862
  a_get("/1/statuses/mentions.json").
414
863
  with(:query => {:count => "20", :include_entities => "false"}).
415
864
  should have_been_made
416
865
  end
417
866
  it "should have the correct output" do
418
- @t.mentions
419
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
420
- sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
421
- sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
422
- sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
423
- sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
424
- sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
425
- sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
426
- sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
427
- sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
428
- sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
429
- sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
430
- sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
431
- sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
432
- sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
433
- sferik: Ping: kills MySpace dead. (about 1 year ago)
434
- sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
435
- sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
436
- sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
437
- sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
438
- sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
867
+ @cli.mentions
868
+ $stdout.string.should == <<-eos
869
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
870
+ TD: @kelseysilver how long will you be in town? (7 months ago)
871
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
872
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
873
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
874
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
875
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
876
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
877
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
878
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
879
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
880
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
881
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
882
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
883
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
884
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
885
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
439
886
  eos
440
887
  end
888
+ context "--long" do
889
+ before do
890
+ @cli.options = @cli.options.merge(:long => true)
891
+ end
892
+ it "should list in long format" do
893
+ @cli.mentions
894
+ $stdout.string.should == <<-eos
895
+ ID Posted at Screen name Text
896
+ 194,548,121,416,630,272 Apr 23 2011 natevillegas RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present.
897
+ 194,547,993,607,806,976 Apr 23 2011 TD @kelseysilver how long will you be in town?
898
+ 194,547,987,593,183,233 Apr 23 2011 rusashka @maciej hahaha :) @gpena together we're going to cover all core 28 languages!
899
+ 194,547,824,690,597,888 Apr 23 2011 fat @stevej @xc i'm going to picket when i get back.
900
+ 194,547,658,562,605,057 Apr 23 2011 wil @0x9900 @paulnivin http://t.co/bwVdtAPe
901
+ 194,547,528,430,137,344 Apr 23 2011 wangtian @tianhonghe @xiangxin72 oh, you can even order specific items?
902
+ 194,547,402,550,689,793 Apr 23 2011 shinypb @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird
903
+ 194,547,260,233,760,768 Apr 23 2011 0x9900 @wil @paulnivin if you want to take you seriously don't say daemontools!
904
+ 194,547,084,349,804,544 Apr 23 2011 kpk @shinypb @skilldrick @hoverbird invented it
905
+ 194,546,876,782,092,291 Apr 23 2011 skilldrick @shinypb Well played :) @hoverbird
906
+ 194,546,811,480,969,217 Apr 23 2011 sam Can someone project the date that I'll get a 27" retina display?
907
+ 194,546,738,810,458,112 Apr 23 2011 shinypb @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain.
908
+ 194,546,727,670,390,784 Apr 23 2011 bartt @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come.
909
+ 194,546,649,203,347,456 Apr 23 2011 skilldrick @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all.
910
+ 194,546,583,608,639,488 Apr 23 2011 sean @mep Thanks for coming by. Was great to have you.
911
+ 194,546,388,707,717,120 Apr 23 2011 hoverbird @shinypb @trammell it's all suck a "duck blur" sometimes.
912
+ 194,546,264,212,385,793 Apr 23 2011 kelseysilver San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw
913
+ eos
914
+ end
915
+ end
916
+ context "--number" do
917
+ before do
918
+ @cli.options = @cli.options.merge(:number => 1)
919
+ stub_get("/1/statuses/mentions.json").
920
+ with(:query => {:count => "1", :include_entities => "false"}).
921
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
922
+ end
923
+ it "should limit the number of results" do
924
+ @cli.mentions
925
+ a_get("/1/statuses/mentions.json").
926
+ with(:query => {:count => "1", :include_entities => "false"}).
927
+ should have_been_made
928
+ end
929
+ end
930
+ context "--reverse" do
931
+ before do
932
+ @cli.options = @cli.options.merge(:reverse => true)
933
+ end
934
+ it "should reverse the order of the sort" do
935
+ @cli.mentions
936
+ $stdout.string.should == <<-eos
937
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
938
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
939
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
940
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
941
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
942
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
943
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
944
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
945
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
946
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
947
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
948
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
949
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
950
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
951
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
952
+ TD: @kelseysilver how long will you be in town? (7 months ago)
953
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
954
+ eos
955
+ end
956
+ end
441
957
  end
442
958
 
443
959
  describe "#open" do
444
960
  before do
445
- @t.options = @t.options.merge(:dry_run => true)
961
+ @cli.options = @cli.options.merge(:dry_run => true)
446
962
  end
447
963
  it "should not raise error" do
448
964
  lambda do
449
- @t.open("sferik")
965
+ @cli.open("sferik")
450
966
  end.should_not raise_error
451
967
  end
452
968
  end
453
969
 
454
970
  describe "#reply" do
455
971
  before do
456
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc", :location => true)
972
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc", :location => true)
457
973
  stub_get("/1/statuses/show/25938088801.json").
458
974
  with(:query => {:include_entities => "false", :include_my_retweet => "false", :trim_user => "true"}).
459
975
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
@@ -466,7 +982,7 @@ describe T::CLI do
466
982
  to_return(:body => fixture("xml.gp"), :headers => {:content_type => "application/xml"})
467
983
  end
468
984
  it "should request the correct resource" do
469
- @t.reply("25938088801", "Testing")
985
+ @cli.reply("25938088801", "Testing")
470
986
  a_get("/1/statuses/show/25938088801.json").
471
987
  with(:query => {:include_entities => "false", :include_my_retweet => "false", :trim_user => "true"}).
472
988
  should have_been_made
@@ -479,82 +995,149 @@ describe T::CLI do
479
995
  should have_been_made
480
996
  end
481
997
  it "should have the correct output" do
482
- @t.reply("25938088801", "Testing")
998
+ @cli.reply("25938088801", "Testing")
483
999
  $stdout.string.should =~ /^Reply created by @testcli to @sferik \(about 1 year ago\)\.$/
484
1000
  end
485
1001
  end
486
1002
 
487
1003
  describe "#report_spam" do
488
1004
  before do
489
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
1005
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
490
1006
  stub_post("/1/report_spam.json").
491
1007
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
492
1008
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
493
1009
  end
494
1010
  it "should request the correct resource" do
495
- @t.report_spam("sferik")
1011
+ @cli.report_spam("sferik")
496
1012
  a_post("/1/report_spam.json").
497
1013
  with(:body => {:screen_name => "sferik", :include_entities => "false"}).
498
1014
  should have_been_made
499
1015
  end
500
1016
  it "should have the correct output" do
501
- @t.report_spam("sferik")
1017
+ @cli.report_spam("sferik")
502
1018
  $stdout.string.should =~ /^@testcli reported @sferik/
503
1019
  end
504
1020
  end
505
1021
 
506
1022
  describe "#retweet" do
507
1023
  before do
508
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
1024
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
509
1025
  stub_post("/1/statuses/retweet/26755176471724032.json").
510
1026
  to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
511
1027
  end
512
1028
  it "should request the correct resource" do
513
- @t.retweet("26755176471724032")
1029
+ @cli.retweet("26755176471724032")
514
1030
  a_post("/1/statuses/retweet/26755176471724032.json").
515
1031
  should have_been_made
516
1032
  end
517
1033
  it "should have the correct output" do
518
- @t.retweet("26755176471724032")
1034
+ @cli.retweet("26755176471724032")
519
1035
  $stdout.string.should =~ /^@testcli retweeted @gruber's status: "As for the Series, I'm for the Giants\. Fuck Texas, fuck Nolan Ryan, fuck George Bush\."$/
520
1036
  end
521
1037
  end
522
1038
 
523
1039
  describe "#retweets" do
1040
+ before do
1041
+ stub_get("/1/statuses/retweeted_by_me.json").
1042
+ with(:query => {:count => "20", :include_entities => "false"}).
1043
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1044
+ end
524
1045
  context "without arguments" do
1046
+ it "should request the correct resource" do
1047
+ @cli.retweets
1048
+ a_get("/1/statuses/retweeted_by_me.json").
1049
+ with(:query => {:count => "20", :include_entities => "false"}).
1050
+ should have_been_made
1051
+ end
1052
+ it "should have the correct output" do
1053
+ @cli.retweets
1054
+ $stdout.string.should == <<-eos
1055
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
1056
+ TD: @kelseysilver how long will you be in town? (7 months ago)
1057
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
1058
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
1059
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
1060
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
1061
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
1062
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
1063
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
1064
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
1065
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
1066
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
1067
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
1068
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
1069
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
1070
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
1071
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
1072
+ eos
1073
+ end
1074
+ end
1075
+ context "--long" do
525
1076
  before do
1077
+ @cli.options = @cli.options.merge(:long => true)
1078
+ end
1079
+ it "should list in long format" do
1080
+ @cli.retweets
1081
+ $stdout.string.should == <<-eos
1082
+ ID Posted at Screen name Text
1083
+ 194,548,121,416,630,272 Apr 23 2011 natevillegas RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present.
1084
+ 194,547,993,607,806,976 Apr 23 2011 TD @kelseysilver how long will you be in town?
1085
+ 194,547,987,593,183,233 Apr 23 2011 rusashka @maciej hahaha :) @gpena together we're going to cover all core 28 languages!
1086
+ 194,547,824,690,597,888 Apr 23 2011 fat @stevej @xc i'm going to picket when i get back.
1087
+ 194,547,658,562,605,057 Apr 23 2011 wil @0x9900 @paulnivin http://t.co/bwVdtAPe
1088
+ 194,547,528,430,137,344 Apr 23 2011 wangtian @tianhonghe @xiangxin72 oh, you can even order specific items?
1089
+ 194,547,402,550,689,793 Apr 23 2011 shinypb @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird
1090
+ 194,547,260,233,760,768 Apr 23 2011 0x9900 @wil @paulnivin if you want to take you seriously don't say daemontools!
1091
+ 194,547,084,349,804,544 Apr 23 2011 kpk @shinypb @skilldrick @hoverbird invented it
1092
+ 194,546,876,782,092,291 Apr 23 2011 skilldrick @shinypb Well played :) @hoverbird
1093
+ 194,546,811,480,969,217 Apr 23 2011 sam Can someone project the date that I'll get a 27" retina display?
1094
+ 194,546,738,810,458,112 Apr 23 2011 shinypb @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain.
1095
+ 194,546,727,670,390,784 Apr 23 2011 bartt @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come.
1096
+ 194,546,649,203,347,456 Apr 23 2011 skilldrick @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all.
1097
+ 194,546,583,608,639,488 Apr 23 2011 sean @mep Thanks for coming by. Was great to have you.
1098
+ 194,546,388,707,717,120 Apr 23 2011 hoverbird @shinypb @trammell it's all suck a "duck blur" sometimes.
1099
+ 194,546,264,212,385,793 Apr 23 2011 kelseysilver San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw
1100
+ eos
1101
+ end
1102
+ end
1103
+ context "--number" do
1104
+ before do
1105
+ @cli.options = @cli.options.merge(:number => 1)
526
1106
  stub_get("/1/statuses/retweeted_by_me.json").
527
- with(:query => {:count => "20", :include_entities => "false"}).
1107
+ with(:query => {:count => "1", :include_entities => "false"}).
528
1108
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
529
1109
  end
530
- it "should request the correct resource" do
531
- @t.retweets
1110
+ it "should limit the number of results" do
1111
+ @cli.retweets
532
1112
  a_get("/1/statuses/retweeted_by_me.json").
533
- with(:query => {:count => "20", :include_entities => "false"}).
1113
+ with(:query => {:count => "1", :include_entities => "false"}).
534
1114
  should have_been_made
535
1115
  end
536
- it "should have the correct output" do
537
- @t.retweets
538
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 4)
539
- sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
540
- sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
541
- sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
542
- sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
543
- sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
544
- sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
545
- sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
546
- sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
547
- sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
548
- sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
549
- sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
550
- sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
551
- sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
552
- sferik: Ping: kills MySpace dead. (about 1 year ago)
553
- sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
554
- sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
555
- sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
556
- sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
557
- sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
1116
+ end
1117
+ context "--reverse" do
1118
+ before do
1119
+ @cli.options = @cli.options.merge(:reverse => true)
1120
+ end
1121
+ it "should reverse the order of the sort" do
1122
+ @cli.retweets
1123
+ $stdout.string.should == <<-eos
1124
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
1125
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
1126
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
1127
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
1128
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
1129
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
1130
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
1131
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
1132
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
1133
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
1134
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
1135
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
1136
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
1137
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
1138
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
1139
+ TD: @kelseysilver how long will you be in town? (7 months ago)
1140
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
558
1141
  eos
559
1142
  end
560
1143
  end
@@ -565,33 +1148,31 @@ describe T::CLI do
565
1148
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
566
1149
  end
567
1150
  it "should request the correct resource" do
568
- @t.retweets("sferik")
1151
+ @cli.retweets("sferik")
569
1152
  a_get("/1/statuses/retweeted_by_user.json").
570
1153
  with(:query => {:count => "20", :include_entities => "false", :screen_name => "sferik"}).
571
1154
  should have_been_made
572
1155
  end
573
1156
  it "should have the correct output" do
574
- @t.retweets("sferik")
575
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 4)
576
- sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
577
- sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
578
- sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
579
- sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
580
- sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
581
- sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
582
- sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
583
- sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
584
- sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
585
- sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
586
- sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
587
- sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
588
- sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
589
- sferik: Ping: kills MySpace dead. (about 1 year ago)
590
- sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
591
- sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
592
- sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
593
- sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
594
- sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
1157
+ @cli.retweets("sferik")
1158
+ $stdout.string.should == <<-eos
1159
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
1160
+ TD: @kelseysilver how long will you be in town? (7 months ago)
1161
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
1162
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
1163
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
1164
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
1165
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
1166
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
1167
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
1168
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
1169
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
1170
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
1171
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
1172
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
1173
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
1174
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
1175
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
595
1176
  eos
596
1177
  end
597
1178
  end
@@ -599,28 +1180,25 @@ describe T::CLI do
599
1180
 
600
1181
  describe "#status" do
601
1182
  before do
602
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc", :location => true)
603
- stub_post("/1/statuses/update.json").
604
- with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
1183
+ stub_get("/1/statuses/show/25938088801.json").
1184
+ with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
605
1185
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
606
- stub_request(:get, "http://checkip.dyndns.org/").
607
- to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
608
- stub_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169").
609
- to_return(:body => fixture("xml.gp"), :headers => {:content_type => "application/xml"})
610
1186
  end
611
1187
  it "should request the correct resource" do
612
- @t.status("Testing")
613
- a_post("/1/statuses/update.json").
614
- with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
615
- should have_been_made
616
- a_request(:get, "http://checkip.dyndns.org/").
617
- should have_been_made
618
- a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169").
1188
+ @cli.status("25938088801")
1189
+ a_get("/1/statuses/show/25938088801.json").
1190
+ with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
619
1191
  should have_been_made
620
1192
  end
621
1193
  it "should have the correct output" do
622
- @t.status("Testing")
623
- $stdout.string.should =~ /^Tweet created by @testcli \(about 1 year ago\)\.$/
1194
+ @cli.status("25938088801")
1195
+ $stdout.string.should == <<-eos
1196
+ Text @noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!
1197
+ Screen name @sferik
1198
+ Posted at Sep 29 2010
1199
+ Source web
1200
+ URL https://twitter.com/sferik/status/25938088801
1201
+ eos
624
1202
  end
625
1203
  end
626
1204
 
@@ -631,52 +1209,212 @@ describe T::CLI do
631
1209
  to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
632
1210
  end
633
1211
  it "should request the correct resource" do
634
- @t.suggest
1212
+ @cli.suggest
635
1213
  a_get("/1/users/recommendations.json").
636
1214
  with(:query => {:limit => "20", :include_entities => "false"}).
637
1215
  should have_been_made
638
1216
  end
639
1217
  it "should have the correct output" do
640
- @t.suggest
1218
+ @cli.suggest
641
1219
  $stdout.string.chomp.rstrip.should == "antpires jtrupiano maccman mlroach stuntmann82"
642
1220
  end
1221
+ context "--created" do
1222
+ before do
1223
+ @cli.options = @cli.options.merge(:created => true)
1224
+ end
1225
+ it "should sort by the time when Twitter acount was created" do
1226
+ @cli.suggest
1227
+ $stdout.string.chomp.rstrip.should == "maccman mlroach jtrupiano stuntmann82 antpires"
1228
+ end
1229
+ end
1230
+ context "--favorites" do
1231
+ before do
1232
+ @cli.options = @cli.options.merge(:favorites => true)
1233
+ end
1234
+ it "should sort by number of favorites" do
1235
+ @cli.suggest
1236
+ $stdout.string.chomp.rstrip.should == "stuntmann82 antpires maccman mlroach jtrupiano"
1237
+ end
1238
+ end
1239
+ context "--followers" do
1240
+ before do
1241
+ @cli.options = @cli.options.merge(:followers => true)
1242
+ end
1243
+ it "should sort by number of followers" do
1244
+ @cli.suggest
1245
+ $stdout.string.chomp.rstrip.should == "stuntmann82 antpires mlroach jtrupiano maccman"
1246
+ end
1247
+ end
1248
+ context "--friends" do
1249
+ before do
1250
+ @cli.options = @cli.options.merge(:friends => true)
1251
+ end
1252
+ it "should sort by number of friends" do
1253
+ @cli.suggest
1254
+ $stdout.string.chomp.rstrip.should == "stuntmann82 antpires mlroach jtrupiano maccman"
1255
+ end
1256
+ end
1257
+ context "--listed" do
1258
+ before do
1259
+ @cli.options = @cli.options.merge(:listed => true)
1260
+ end
1261
+ it "should sort by number of list memberships" do
1262
+ @cli.suggest
1263
+ $stdout.string.chomp.rstrip.should == "stuntmann82 antpires mlroach jtrupiano maccman"
1264
+ end
1265
+ end
1266
+ context "--long" do
1267
+ before do
1268
+ @cli.options = @cli.options.merge(:long => true)
1269
+ end
1270
+ it "should list in long format" do
1271
+ @cli.suggest
1272
+ $stdout.string.should == <<-eos
1273
+ ID Since Tweets Favorites Listed Following Followers Screen name Name
1274
+ 40,514,587 May 16 2009 183 2 2 198 158 antpires AntonioPires
1275
+ 14,736,332 May 11 2008 3,850 117 99 545 802 jtrupiano John Trupiano
1276
+ 2,006,261 Mar 23 2007 4,497 9 171 967 2,028 maccman Alex MacCaw
1277
+ 14,451,152 Apr 20 2008 6,251 10 20 403 299 mlroach Matt Laroche
1278
+ 16,052,754 Aug 30 2008 24 0 1 5 42 stuntmann82 stuntmann82
1279
+ eos
1280
+ end
1281
+ end
1282
+ context "--number" do
1283
+ before do
1284
+ @cli.options = @cli.options.merge(:number => 1)
1285
+ stub_get("/1/users/recommendations.json").
1286
+ with(:query => {:limit => "1", :include_entities => "false"}).
1287
+ to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1288
+ end
1289
+ it "should limit the number of results" do
1290
+ @cli.suggest
1291
+ a_get("/1/users/recommendations.json").
1292
+ with(:query => {:limit => "1", :include_entities => "false"}).
1293
+ should have_been_made
1294
+ end
1295
+ end
1296
+ context "--reverse" do
1297
+ before do
1298
+ @cli.options = @cli.options.merge(:reverse => true)
1299
+ end
1300
+ it "should reverse the order of the sort" do
1301
+ @cli.suggest
1302
+ $stdout.string.chomp.rstrip.should == "stuntmann82 mlroach maccman jtrupiano antpires"
1303
+ end
1304
+ end
1305
+ context "--tweets" do
1306
+ before do
1307
+ @cli.options = @cli.options.merge(:tweets => true)
1308
+ end
1309
+ it "should sort by number of Tweets" do
1310
+ @cli.suggest
1311
+ $stdout.string.chomp.rstrip.should == "stuntmann82 antpires jtrupiano maccman mlroach"
1312
+ end
1313
+ end
643
1314
  end
644
1315
 
645
1316
  describe "#timeline" do
1317
+ before do
1318
+ stub_get("/1/statuses/home_timeline.json").
1319
+ with(:query => {:count => "20", :include_entities => "false"}).
1320
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1321
+ end
646
1322
  context "without user" do
1323
+ it "should request the correct resource" do
1324
+ @cli.timeline
1325
+ a_get("/1/statuses/home_timeline.json").
1326
+ with(:query => {:count => "20", :include_entities => "false"}).
1327
+ should have_been_made
1328
+ end
1329
+ it "should have the correct output" do
1330
+ @cli.timeline
1331
+ $stdout.string.should == <<-eos
1332
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
1333
+ TD: @kelseysilver how long will you be in town? (7 months ago)
1334
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
1335
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
1336
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
1337
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
1338
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
1339
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
1340
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
1341
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
1342
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
1343
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
1344
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
1345
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
1346
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
1347
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
1348
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
1349
+ eos
1350
+ end
1351
+ end
1352
+ context "--long" do
1353
+ before do
1354
+ @cli.options = @cli.options.merge(:long => true)
1355
+ end
1356
+ it "should list in long format" do
1357
+ @cli.timeline
1358
+ $stdout.string.should == <<-eos
1359
+ ID Posted at Screen name Text
1360
+ 194,548,121,416,630,272 Apr 23 2011 natevillegas RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present.
1361
+ 194,547,993,607,806,976 Apr 23 2011 TD @kelseysilver how long will you be in town?
1362
+ 194,547,987,593,183,233 Apr 23 2011 rusashka @maciej hahaha :) @gpena together we're going to cover all core 28 languages!
1363
+ 194,547,824,690,597,888 Apr 23 2011 fat @stevej @xc i'm going to picket when i get back.
1364
+ 194,547,658,562,605,057 Apr 23 2011 wil @0x9900 @paulnivin http://t.co/bwVdtAPe
1365
+ 194,547,528,430,137,344 Apr 23 2011 wangtian @tianhonghe @xiangxin72 oh, you can even order specific items?
1366
+ 194,547,402,550,689,793 Apr 23 2011 shinypb @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird
1367
+ 194,547,260,233,760,768 Apr 23 2011 0x9900 @wil @paulnivin if you want to take you seriously don't say daemontools!
1368
+ 194,547,084,349,804,544 Apr 23 2011 kpk @shinypb @skilldrick @hoverbird invented it
1369
+ 194,546,876,782,092,291 Apr 23 2011 skilldrick @shinypb Well played :) @hoverbird
1370
+ 194,546,811,480,969,217 Apr 23 2011 sam Can someone project the date that I'll get a 27" retina display?
1371
+ 194,546,738,810,458,112 Apr 23 2011 shinypb @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain.
1372
+ 194,546,727,670,390,784 Apr 23 2011 bartt @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come.
1373
+ 194,546,649,203,347,456 Apr 23 2011 skilldrick @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all.
1374
+ 194,546,583,608,639,488 Apr 23 2011 sean @mep Thanks for coming by. Was great to have you.
1375
+ 194,546,388,707,717,120 Apr 23 2011 hoverbird @shinypb @trammell it's all suck a "duck blur" sometimes.
1376
+ 194,546,264,212,385,793 Apr 23 2011 kelseysilver San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw
1377
+ eos
1378
+ end
1379
+ end
1380
+ context "--number" do
647
1381
  before do
1382
+ @cli.options = @cli.options.merge(:number => 1)
648
1383
  stub_get("/1/statuses/home_timeline.json").
649
- with(:query => {:count => "20", :include_entities => "false"}).
1384
+ with(:query => {:count => "1", :include_entities => "false"}).
650
1385
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
651
1386
  end
652
- it "should request the correct resource" do
653
- @t.timeline
1387
+ it "should limit the number of results" do
1388
+ @cli.timeline
654
1389
  a_get("/1/statuses/home_timeline.json").
655
- with(:query => {:count => "20", :include_entities => "false"}).
1390
+ with(:query => {:count => "1", :include_entities => "false"}).
656
1391
  should have_been_made
657
1392
  end
658
- it "should have the correct output" do
659
- @t.timeline
660
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 4)
661
- sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
662
- sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
663
- sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
664
- sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
665
- sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
666
- sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
667
- sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
668
- sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
669
- sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
670
- sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
671
- sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
672
- sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
673
- sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
674
- sferik: Ping: kills MySpace dead. (about 1 year ago)
675
- sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
676
- sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
677
- sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
678
- sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
679
- sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
1393
+ end
1394
+ context "--reverse" do
1395
+ before do
1396
+ @cli.options = @cli.options.merge(:reverse => true)
1397
+ end
1398
+ it "should reverse the order of the sort" do
1399
+ @cli.timeline
1400
+ $stdout.string.should == <<-eos
1401
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
1402
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
1403
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
1404
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
1405
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
1406
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
1407
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
1408
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
1409
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
1410
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
1411
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
1412
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
1413
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
1414
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
1415
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
1416
+ TD: @kelseysilver how long will you be in town? (7 months ago)
1417
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
680
1418
  eos
681
1419
  end
682
1420
  end
@@ -687,33 +1425,31 @@ describe T::CLI do
687
1425
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
688
1426
  end
689
1427
  it "should request the correct resource" do
690
- @t.timeline("sferik")
1428
+ @cli.timeline("sferik")
691
1429
  a_get("/1/statuses/user_timeline.json").
692
1430
  with(:query => {:count => "20", :include_entities => "false", :screen_name => "sferik"}).
693
1431
  should have_been_made
694
1432
  end
695
1433
  it "should have the correct output" do
696
- @t.timeline("sferik")
697
- $stdout.string.should == <<-eos.gsub(/^/, ' ' * 4)
698
- sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
699
- sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
700
- sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
701
- sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
702
- sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
703
- sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
704
- sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
705
- sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
706
- sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
707
- sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
708
- sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
709
- sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
710
- sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
711
- sferik: Ping: kills MySpace dead. (about 1 year ago)
712
- sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
713
- sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
714
- sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
715
- sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
716
- sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
1434
+ @cli.timeline("sferik")
1435
+ $stdout.string.should == <<-eos
1436
+ natevillegas: RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it's called the present. (7 months ago)
1437
+ TD: @kelseysilver how long will you be in town? (7 months ago)
1438
+ rusashka: @maciej hahaha :) @gpena together we're going to cover all core 28 languages! (7 months ago)
1439
+ fat: @stevej @xc i'm going to picket when i get back. (7 months ago)
1440
+ wil: @0x9900 @paulnivin http://t.co/bwVdtAPe (7 months ago)
1441
+ wangtian: @tianhonghe @xiangxin72 oh, you can even order specific items? (7 months ago)
1442
+ shinypb: @kpk Pfft, I think you're forgetting mechanical television, which depended on a clever German. http://t.co/JvLNQCDm @skilldrick @hoverbird (7 months ago)
1443
+ 0x9900: @wil @paulnivin if you want to take you seriously don't say daemontools! (7 months ago)
1444
+ kpk: @shinypb @skilldrick @hoverbird invented it (7 months ago)
1445
+ skilldrick: @shinypb Well played :) @hoverbird (7 months ago)
1446
+ sam: Can someone project the date that I'll get a 27" retina display? (7 months ago)
1447
+ shinypb: @skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain. (7 months ago)
1448
+ bartt: @noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come. (7 months ago)
1449
+ skilldrick: @hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all. (7 months ago)
1450
+ sean: @mep Thanks for coming by. Was great to have you. (7 months ago)
1451
+ hoverbird: @shinypb @trammell it's all suck a "duck blur" sometimes. (7 months ago)
1452
+ kelseysilver: San Francisco here I come! (@ Newark Liberty International Airport (EWR) w/ 92 others) http://t.co/eoLANJZw (7 months ago)
717
1453
  eos
718
1454
  end
719
1455
  end
@@ -721,12 +1457,12 @@ describe T::CLI do
721
1457
 
722
1458
  describe "#unfollow" do
723
1459
  before do
724
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
1460
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc")
725
1461
  end
726
1462
  context "no users" do
727
1463
  it "should exit" do
728
1464
  lambda do
729
- @t.unfollow
1465
+ @cli.unfollow
730
1466
  end.should raise_error
731
1467
  end
732
1468
  end
@@ -735,7 +1471,7 @@ describe T::CLI do
735
1471
  stub_delete("/1/friendships/destroy.json").
736
1472
  with(:query => {:screen_name => "sferik", :include_entities => "false"}).
737
1473
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
738
- @t.unfollow("sferik")
1474
+ @cli.unfollow("sferik")
739
1475
  a_delete("/1/friendships/destroy.json").
740
1476
  with(:query => {:screen_name => "sferik", :include_entities => "false"}).
741
1477
  should have_been_made
@@ -744,7 +1480,7 @@ describe T::CLI do
744
1480
  stub_delete("/1/friendships/destroy.json").
745
1481
  with(:query => {:screen_name => "sferik", :include_entities => "false"}).
746
1482
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
747
- @t.unfollow("sferik")
1483
+ @cli.unfollow("sferik")
748
1484
  $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
749
1485
  end
750
1486
  context "Twitter is down" do
@@ -753,7 +1489,7 @@ describe T::CLI do
753
1489
  with(:query => {:screen_name => "sferik", :include_entities => "false"}).
754
1490
  to_return(:status => 502)
755
1491
  lambda do
756
- @t.unfollow("sferik")
1492
+ @cli.unfollow("sferik")
757
1493
  end.should raise_error("Twitter is down or being upgraded.")
758
1494
  a_delete("/1/friendships/destroy.json").
759
1495
  with(:query => {:screen_name => "sferik", :include_entities => "false"}).
@@ -763,27 +1499,130 @@ describe T::CLI do
763
1499
  end
764
1500
  end
765
1501
 
1502
+ describe "#update" do
1503
+ before do
1504
+ @cli.options = @cli.options.merge(:profile => fixture_path + "/.trc", :location => true)
1505
+ stub_post("/1/statuses/update.json").
1506
+ with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
1507
+ to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1508
+ stub_request(:get, "http://checkip.dyndns.org/").
1509
+ to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
1510
+ stub_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169").
1511
+ to_return(:body => fixture("xml.gp"), :headers => {:content_type => "application/xml"})
1512
+ end
1513
+ it "should request the correct resource" do
1514
+ @cli.update("Testing")
1515
+ a_post("/1/statuses/update.json").
1516
+ with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
1517
+ should have_been_made
1518
+ a_request(:get, "http://checkip.dyndns.org/").
1519
+ should have_been_made
1520
+ a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169").
1521
+ should have_been_made
1522
+ end
1523
+ it "should have the correct output" do
1524
+ @cli.update("Testing")
1525
+ $stdout.string.should =~ /^Tweet created by @testcli \(about 1 year ago\)\.$/
1526
+ end
1527
+ end
1528
+
766
1529
  describe "#users" do
767
1530
  before do
768
1531
  stub_get("/1/users/lookup.json").
769
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
1532
+ with(:query => {:screen_name => "sferik,pengwynn", :include_entities => "false"}).
770
1533
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
771
1534
  end
772
1535
  it "should request the correct resource" do
773
- @t.users("sferik")
1536
+ @cli.users("sferik", "pengwynn")
774
1537
  a_get("/1/users/lookup.json").
775
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
1538
+ with(:query => {:screen_name => "sferik,pengwynn", :include_entities => "false"}).
776
1539
  should have_been_made
777
1540
  end
778
1541
  it "should have the correct output" do
779
- @t.users("sferik")
1542
+ @cli.users("sferik", "pengwynn")
780
1543
  $stdout.string.chomp.rstrip.should == "pengwynn sferik"
781
1544
  end
1545
+ context "--created" do
1546
+ before do
1547
+ @cli.options = @cli.options.merge(:created => true)
1548
+ end
1549
+ it "should sort by the time when Twitter acount was created" do
1550
+ @cli.users("sferik", "pengwynn")
1551
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
1552
+ end
1553
+ end
1554
+ context "--favorites" do
1555
+ before do
1556
+ @cli.options = @cli.options.merge(:favorites => true)
1557
+ end
1558
+ it "should sort by number of favorites" do
1559
+ @cli.users("sferik", "pengwynn")
1560
+ $stdout.string.chomp.rstrip.should == "pengwynn sferik"
1561
+ end
1562
+ end
1563
+ context "--followers" do
1564
+ before do
1565
+ @cli.options = @cli.options.merge(:followers => true)
1566
+ end
1567
+ it "should sort by number of followers" do
1568
+ @cli.users("sferik", "pengwynn")
1569
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
1570
+ end
1571
+ end
1572
+ context "--friends" do
1573
+ before do
1574
+ @cli.options = @cli.options.merge(:friends => true)
1575
+ end
1576
+ it "should sort by number of friends" do
1577
+ @cli.users("sferik", "pengwynn")
1578
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
1579
+ end
1580
+ end
1581
+ context "--listed" do
1582
+ before do
1583
+ @cli.options = @cli.options.merge(:listed => true)
1584
+ end
1585
+ it "should sort by number of list memberships" do
1586
+ @cli.users("sferik", "pengwynn")
1587
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
1588
+ end
1589
+ end
1590
+ context "--long" do
1591
+ before do
1592
+ @cli.options = @cli.options.merge(:long => true)
1593
+ end
1594
+ it "should list in long format" do
1595
+ @cli.users("sferik", "pengwynn")
1596
+ $stdout.string.should == <<-eos
1597
+ ID Since Tweets Favorites Listed Following Followers Screen name Name
1598
+ 14,100,886 Mar 8 2008 3,913 32 185 1,871 2,767 pengwynn Wynn Netherland
1599
+ 7,505,382 Jul 16 2007 2,962 727 29 88 898 sferik Erik Michaels-Ober
1600
+ eos
1601
+ end
1602
+ end
1603
+ context "--reverse" do
1604
+ before do
1605
+ @cli.options = @cli.options.merge(:reverse => true)
1606
+ end
1607
+ it "should reverse the order of the sort" do
1608
+ @cli.users("sferik", "pengwynn")
1609
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
1610
+ end
1611
+ end
1612
+ context "--tweets" do
1613
+ before do
1614
+ @cli.options = @cli.options.merge(:tweets => true)
1615
+ end
1616
+ it "should sort by number of Tweets" do
1617
+ @cli.users("sferik", "pengwynn")
1618
+ $stdout.string.chomp.rstrip.should == "sferik pengwynn"
1619
+ end
1620
+ end
782
1621
  end
783
1622
 
784
1623
  describe "#version" do
785
1624
  it "should have the correct output" do
786
- @t.version
1625
+ @cli.version
787
1626
  $stdout.string.chomp.should == T::Version.to_s
788
1627
  end
789
1628
  end
@@ -795,19 +1634,27 @@ describe T::CLI do
795
1634
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
796
1635
  end
797
1636
  it "should request the correct resource" do
798
- @t.whois("sferik")
1637
+ @cli.whois("sferik")
799
1638
  a_get("/1/users/show.json").
800
1639
  with(:query => {:screen_name => "sferik", :include_entities => "false"}).
801
1640
  should have_been_made
802
1641
  end
803
1642
  it "should have the correct output" do
804
- @t.whois("sferik")
805
- $stdout.string.should == <<-eos.gsub(/^ {8}/, '')
806
- id: #7,505,382
807
- Erik Michaels-Ober, since Jul 2007.
808
- bio: A mind forever voyaging through strange seas of thought, alone.
809
- location: San Francisco
810
- web: https://github.com/sferik
1643
+ @cli.whois("sferik")
1644
+ $stdout.string.should == <<-eos
1645
+ ID 7,505,382
1646
+ Name Erik Michaels-Ober
1647
+ Bio A mind forever voyaging through strange seas of thought, alone.
1648
+ Location San Francisco
1649
+ URL https://github.com/sferik
1650
+ Status Not following
1651
+ Last update RT @tenderlove: [ANN] sqlite3-ruby =&gt; sqlite3 (10 months ago)
1652
+ Since Jul 16 2007
1653
+ Tweets 3,479
1654
+ Favorites 1,040
1655
+ Listed 41
1656
+ Following 197
1657
+ Followers 1,048
811
1658
  eos
812
1659
  end
813
1660
  end