t 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -116,12 +116,11 @@ module T
116
116
 
117
117
  def print_status(status)
118
118
  if STDOUT.tty? && !options['no-color']
119
- say(" #{Thor::Shell::Color::BOLD}@#{status.user.screen_name}", :yellow)
120
- print_wrapped(HTMLEntities.new.decode(status.text), :indent => 3)
119
+ say(" @#{status.user.screen_name}", [:bold, :yellow])
121
120
  else
122
121
  say(" @#{status.user.screen_name}")
123
- print_wrapped(HTMLEntities.new.decode(status.text), :indent => 3)
124
122
  end
123
+ print_wrapped(HTMLEntities.new.decode(status.text), :indent => 3)
125
124
  say
126
125
  end
127
126
 
@@ -34,7 +34,9 @@ module T
34
34
  method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS
35
35
  def all(query)
36
36
  rpp = options['number'] || DEFAULT_NUM_RESULTS
37
- statuses = client.search(query, :include_entities => false, :rpp => rpp)
37
+ statuses = collect_with_rpp(rpp) do |opts|
38
+ client.search(query, opts)
39
+ end
38
40
  if options['csv']
39
41
  say ["ID", "Posted at", "Screen name", "Text"].to_csv unless statuses.empty?
40
42
  statuses.each do |status|
@@ -56,12 +58,11 @@ module T
56
58
  say unless statuses.empty?
57
59
  statuses.each do |status|
58
60
  if STDOUT.tty? && !options['no-color']
59
- say(" #{Thor::Shell::Color::BOLD}@#{status.from_user}", :yellow)
60
- print_wrapped(HTMLEntities.new.decode(status.text), :indent => 3)
61
+ say(" @#{status.from_user}", [:bold, :yellow])
61
62
  else
62
63
  say(" @#{status.from_user}")
63
- print_wrapped(HTMLEntities.new.decode(status.text), :indent => 3)
64
64
  end
65
+ print_wrapped(HTMLEntities.new.decode(status.text), :indent => 3)
65
66
  say
66
67
  end
67
68
  end
@@ -26,7 +26,7 @@ module T
26
26
 
27
27
  desc "bio DESCRIPTION", "Edits your Bio information on your Twitter profile."
28
28
  def bio(description)
29
- client.update_profile(:description => description, :include_entities => false)
29
+ client.update_profile(:description => description)
30
30
  say "@#{@rcfile.active_profile[0]}'s bio has been updated."
31
31
  end
32
32
 
@@ -38,19 +38,19 @@ module T
38
38
 
39
39
  desc "location PLACE_NAME", "Updates the location field in your profile."
40
40
  def location(place_name)
41
- client.update_profile(:location => place_name, :include_entities => false)
41
+ client.update_profile(:location => place_name)
42
42
  say "@#{@rcfile.active_profile[0]}'s location has been updated."
43
43
  end
44
44
 
45
45
  desc "name NAME", "Sets the name field on your Twitter profile."
46
46
  def name(name)
47
- client.update_profile(:name => name, :include_entities => false)
47
+ client.update_profile(:name => name)
48
48
  say "@#{@rcfile.active_profile[0]}'s name has been updated."
49
49
  end
50
50
 
51
51
  desc "url URL", "Sets the URL field on your profile."
52
52
  def url(url)
53
- client.update_profile(:url => url, :include_entities => false)
53
+ client.update_profile(:url => url)
54
54
  say "@#{@rcfile.active_profile[0]}'s URL has been updated."
55
55
  end
56
56
 
@@ -1,4 +1,3 @@
1
- require 't/cli'
2
1
  require 't/printable'
3
2
  require 't/rcfile'
4
3
  require 't/search'
@@ -37,7 +36,7 @@ module T
37
36
  desc "matrix", "Unfortunately, no one can be told what the Matrix is. You have to see it for yourself."
38
37
  def matrix
39
38
  client.on_timeline_status do |status|
40
- print("#{Thor::Shell::Color::BOLD}#{Thor::Shell::Color::GREEN}#{Thor::Shell::Color::ON_BLACK}#{status.text.gsub("\n", '')}#{Thor::Shell::Color::CLEAR}")
39
+ say(status.text.gsub("\n", ''), [:bold, :green, :on_black])
41
40
  end
42
41
  Signal.trap("TERM") do
43
42
  client.stop
@@ -13,7 +13,7 @@ module T
13
13
 
14
14
  # @return [Integer]
15
15
  def self.patch
16
- 4
16
+ 5
17
17
  end
18
18
 
19
19
  # @return [String, NilClass]
@@ -71,13 +71,13 @@ testcli
71
71
  before do
72
72
  @cli.options = @cli.options.merge("profile" => fixture_path + "/.trc")
73
73
  stub_post("/1/blocks/create.json").
74
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
74
+ with(:body => {:screen_name => "sferik"}).
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
78
  @cli.block("sferik")
79
79
  a_post("/1/blocks/create.json").
80
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
80
+ with(:body => {:screen_name => "sferik"}).
81
81
  should have_been_made
82
82
  end
83
83
  it "should have the correct output" do
@@ -88,13 +88,13 @@ testcli
88
88
  before do
89
89
  @cli.options = @cli.options.merge("id" => true)
90
90
  stub_post("/1/blocks/create.json").
91
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
91
+ with(:body => {:user_id => "7505382"}).
92
92
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
93
93
  end
94
94
  it "should request the correct resource" do
95
95
  @cli.block("7505382")
96
96
  a_post("/1/blocks/create.json").
97
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
97
+ with(:body => {:user_id => "7505382"}).
98
98
  should have_been_made
99
99
  end
100
100
  end
@@ -103,13 +103,13 @@ testcli
103
103
  describe "#direct_messages" do
104
104
  before do
105
105
  stub_get("/1/direct_messages.json").
106
- with(:query => {:count => "20", :include_entities => "false"}).
106
+ with(:query => {:count => "20"}).
107
107
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
108
108
  end
109
109
  it "should request the correct resource" do
110
110
  @cli.direct_messages
111
111
  a_get("/1/direct_messages.json").
112
- with(:query => {:count => "20", :include_entities => "false"}).
112
+ with(:query => {:count => "20"}).
113
113
  should have_been_made
114
114
  end
115
115
  it "should have the correct output" do
@@ -171,15 +171,31 @@ ID Posted at Screen name Text
171
171
  end
172
172
  context "--number" do
173
173
  before do
174
- @cli.options = @cli.options.merge("number" => 1)
175
174
  stub_get("/1/direct_messages.json").
176
- with(:query => {:count => "1", :include_entities => "false"}).
175
+ with(:query => {:count => "1"}).
176
+ to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
177
+ stub_get("/1/direct_messages.json").
178
+ with(:query => {:count => "200"}).
177
179
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
180
+ stub_get("/1/direct_messages.json").
181
+ with(:query => {:count => "145", :max_id => "1624782205"}).
182
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
178
183
  end
179
- it "should limit the number of results" do
184
+ it "should limit the number of results to 1" do
185
+ @cli.options = @cli.options.merge("number" => 1)
180
186
  @cli.direct_messages
181
187
  a_get("/1/direct_messages.json").
182
- with(:query => {:count => "1", :include_entities => "false"}).
188
+ with(:query => {:count => "1"}).
189
+ should have_been_made
190
+ end
191
+ it "should limit the number of results to 345" do
192
+ @cli.options = @cli.options.merge("number" => 345)
193
+ @cli.direct_messages
194
+ a_get("/1/direct_messages.json").
195
+ with(:query => {:count => "200"}).
196
+ should have_been_made
197
+ a_get("/1/direct_messages.json").
198
+ with(:query => {:count => "145", :max_id => "1624782205"}).
183
199
  should have_been_made
184
200
  end
185
201
  end
@@ -208,13 +224,13 @@ ID Posted at Screen name Text
208
224
  describe "#direct_messages_sent" do
209
225
  before do
210
226
  stub_get("/1/direct_messages/sent.json").
211
- with(:query => {:count => "20", :include_entities => "false"}).
227
+ with(:query => {:count => "20"}).
212
228
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
213
229
  end
214
230
  it "should request the correct resource" do
215
231
  @cli.direct_messages_sent
216
232
  a_get("/1/direct_messages/sent.json").
217
- with(:query => {:count => "20", :include_entities => "false"}).
233
+ with(:query => {:count => "20"}).
218
234
  should have_been_made
219
235
  end
220
236
  it "should have the correct output" do
@@ -276,15 +292,31 @@ ID Posted at Screen name Text
276
292
  end
277
293
  context "--number" do
278
294
  before do
279
- @cli.options = @cli.options.merge("number" => 1)
280
295
  stub_get("/1/direct_messages/sent.json").
281
- with(:query => {:count => "1", :include_entities => "false"}).
296
+ with(:query => {:count => "1"}).
297
+ to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
298
+ stub_get("/1/direct_messages/sent.json").
299
+ with(:query => {:count => "200"}).
300
+ to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
301
+ stub_get("/1/direct_messages/sent.json").
302
+ with(:query => {:count => "145", :max_id => "1624782205"}).
282
303
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
283
304
  end
284
- it "should limit the number of results" do
305
+ it "should limit the number of results 1" do
306
+ @cli.options = @cli.options.merge("number" => 1)
285
307
  @cli.direct_messages_sent
286
308
  a_get("/1/direct_messages/sent.json").
287
- with(:query => {:count => "1", :include_entities => "false"}).
309
+ with(:query => {:count => "1"}).
310
+ should have_been_made
311
+ end
312
+ it "should limit the number of results to 345" do
313
+ @cli.options = @cli.options.merge("number" => 345)
314
+ @cli.direct_messages_sent
315
+ a_get("/1/direct_messages/sent.json").
316
+ with(:query => {:count => "200"}).
317
+ should have_been_made
318
+ a_get("/1/direct_messages/sent.json").
319
+ with(:query => {:count => "145", :max_id => "1624782205"}).
288
320
  should have_been_made
289
321
  end
290
322
  end
@@ -319,7 +351,7 @@ ID Posted at Screen name Text
319
351
  with(:query => {:cursor => "-1"}).
320
352
  to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
321
353
  stub_get("/1/users/lookup.json").
322
- with(:query => {:user_id => "213747670,428004849", :include_entities => "false"}).
354
+ with(:query => {:user_id => "213747670,428004849"}).
323
355
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
324
356
  end
325
357
  it "should request the correct resource" do
@@ -331,7 +363,7 @@ ID Posted at Screen name Text
331
363
  with(:query => {:cursor => "-1"}).
332
364
  should have_been_made
333
365
  a_get("/1/users/lookup.json").
334
- with(:query => {:user_id => "213747670,428004849", :include_entities => "false"}).
366
+ with(:query => {:user_id => "213747670,428004849"}).
335
367
  should have_been_made
336
368
  end
337
369
  it "should have the correct output" do
@@ -454,7 +486,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
454
486
  with(:query => {:cursor => "-1", :screen_name => "sferik"}).
455
487
  should have_been_made
456
488
  a_get("/1/users/lookup.json").
457
- with(:query => {:user_id => "213747670,428004849", :include_entities => "false"}).
489
+ with(:query => {:user_id => "213747670,428004849"}).
458
490
  should have_been_made
459
491
  end
460
492
  context "--id" do
@@ -476,7 +508,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
476
508
  with(:query => {:cursor => "-1", :user_id => "7505382"}).
477
509
  should have_been_made
478
510
  a_get("/1/users/lookup.json").
479
- with(:query => {:user_id => "213747670,428004849", :include_entities => "false"}).
511
+ with(:query => {:user_id => "213747670,428004849"}).
480
512
  should have_been_made
481
513
  end
482
514
  end
@@ -487,13 +519,13 @@ ID Since Tweets Favorites Listed Following Followers Scre...
487
519
  before do
488
520
  @cli.options = @cli.options.merge("profile" => fixture_path + "/.trc")
489
521
  stub_post("/1/direct_messages/new.json").
490
- with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
522
+ with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
491
523
  to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
492
524
  end
493
525
  it "should request the correct resource" do
494
526
  @cli.dm("pengwynn", "Creating a fixture for the Twitter gem")
495
527
  a_post("/1/direct_messages/new.json").
496
- with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
528
+ with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
497
529
  should have_been_made
498
530
  end
499
531
  it "should have the correct output" do
@@ -504,13 +536,13 @@ ID Since Tweets Favorites Listed Following Followers Scre...
504
536
  before do
505
537
  @cli.options = @cli.options.merge("id" => true)
506
538
  stub_post("/1/direct_messages/new.json").
507
- with(:body => {:user_id => "14100886", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
539
+ with(:body => {:user_id => "14100886", :text => "Creating a fixture for the Twitter gem"}).
508
540
  to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
509
541
  end
510
542
  it "should request the correct resource" do
511
543
  @cli.dm("14100886", "Creating a fixture for the Twitter gem")
512
544
  a_post("/1/direct_messages/new.json").
513
- with(:body => {:user_id => "14100886", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
545
+ with(:body => {:user_id => "14100886", :text => "Creating a fixture for the Twitter gem"}).
514
546
  should have_been_made
515
547
  end
516
548
  end
@@ -537,7 +569,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
537
569
  before do
538
570
  @cli.options = @cli.options.merge("id" => true)
539
571
  stub_get("/1/users/show.json").
540
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
572
+ with(:query => {:user_id => "7505382"}).
541
573
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
542
574
  stub_get("/1/lists/members/show.json").
543
575
  with(:query => {:owner_screen_name => "testcli", :screen_name => "sferik", :slug => "presidents"}).
@@ -546,7 +578,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
546
578
  it "should request the correct resource" do
547
579
  @cli.does_contain("presidents", "7505382")
548
580
  a_get("/1/users/show.json").
549
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
581
+ with(:query => {:user_id => "7505382"}).
550
582
  should have_been_made
551
583
  a_get("/1/lists/members/show.json").
552
584
  with(:query => {:owner_screen_name => "testcli", :screen_name => "sferik", :slug => "presidents"}).
@@ -562,7 +594,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
562
594
  before do
563
595
  @cli.options = @cli.options.merge("id" => true)
564
596
  stub_get("/1/users/show.json").
565
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
597
+ with(:query => {:user_id => "7505382"}).
566
598
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
567
599
  stub_get("/1/lists/members/show.json").
568
600
  with(:query => {:owner_screen_name => "sferik", :screen_name => "sferik", :slug => "presidents"}).
@@ -571,7 +603,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
571
603
  it "should request the correct resource" do
572
604
  @cli.does_contain("7505382/presidents", "7505382")
573
605
  a_get("/1/users/show.json").
574
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
606
+ with(:query => {:user_id => "7505382"}).
575
607
  should have_been_made.times(2)
576
608
  a_get("/1/lists/members/show.json").
577
609
  with(:query => {:owner_screen_name => "sferik", :screen_name => "sferik", :slug => "presidents"}).
@@ -623,7 +655,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
623
655
  before do
624
656
  @cli.options = @cli.options.merge("id" => true)
625
657
  stub_get("/1/users/show.json").
626
- with(:query => {:user_id => "20", :include_entities => "false"}).
658
+ with(:query => {:user_id => "20"}).
627
659
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
628
660
  stub_get("/1/friendships/exists.json").
629
661
  with(:query => {:user_a => "sferik", :user_b => "testcli"}).
@@ -632,7 +664,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
632
664
  it "should request the correct resource" do
633
665
  @cli.does_follow("20")
634
666
  a_get("/1/users/show.json").
635
- with(:query => {:user_id => "20", :include_entities => "false"}).
667
+ with(:query => {:user_id => "20"}).
636
668
  should have_been_made
637
669
  a_get("/1/friendships/exists.json").
638
670
  with(:query => {:user_a => "sferik", :user_b => "testcli"}).
@@ -648,10 +680,10 @@ ID Since Tweets Favorites Listed Following Followers Scre...
648
680
  before do
649
681
  @cli.options = @cli.options.merge("id" => true)
650
682
  stub_get("/1/users/show.json").
651
- with(:query => {:user_id => "20", :include_entities => "false"}).
683
+ with(:query => {:user_id => "20"}).
652
684
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
653
685
  stub_get("/1/users/show.json").
654
- with(:query => {:user_id => "428004849", :include_entities => "false"}).
686
+ with(:query => {:user_id => "428004849"}).
655
687
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
656
688
  stub_get("/1/friendships/exists.json").
657
689
  with(:query => {:user_a => "sferik", :user_b => "sferik"}).
@@ -660,10 +692,10 @@ ID Since Tweets Favorites Listed Following Followers Scre...
660
692
  it "should request the correct resource" do
661
693
  @cli.does_follow("20", "428004849")
662
694
  a_get("/1/users/show.json").
663
- with(:query => {:user_id => "20", :include_entities => "false"}).
695
+ with(:query => {:user_id => "20"}).
664
696
  should have_been_made
665
697
  a_get("/1/users/show.json").
666
- with(:query => {:user_id => "428004849", :include_entities => "false"}).
698
+ with(:query => {:user_id => "428004849"}).
667
699
  should have_been_made
668
700
  a_get("/1/friendships/exists.json").
669
701
  with(:query => {:user_a => "sferik", :user_b => "sferik"}).
@@ -708,13 +740,13 @@ ID Since Tweets Favorites Listed Following Followers Scre...
708
740
  describe "#favorites" do
709
741
  before do
710
742
  stub_get("/1/favorites.json").
711
- with(:query => {:count => "20", :include_entities => "false"}).
743
+ with(:query => {:count => "20"}).
712
744
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
713
745
  end
714
746
  it "should request the correct resource" do
715
747
  @cli.favorites
716
748
  a_get("/1/favorites.json").
717
- with(:query => {:count => "20", :include_entities => "false"}).
749
+ with(:query => {:count => "20"}).
718
750
  should have_been_made
719
751
  end
720
752
  it "should have the correct output" do
@@ -809,41 +841,57 @@ ID Posted at Screen name Text
809
841
  end
810
842
  context "--number" do
811
843
  before do
812
- @cli.options = @cli.options.merge("number" => 1)
813
844
  stub_get("/1/favorites.json").
814
- with(:query => {:count => "1", :include_entities => "false"}).
845
+ with(:query => {:count => "1"}).
815
846
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
847
+ stub_get("/1/favorites.json").
848
+ with(:query => {:count => "200"}).
849
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
850
+ stub_get("/1/favorites.json").
851
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
852
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
816
853
  end
817
- it "should limit the number of results" do
854
+ it "should limit the number of results to 1" do
855
+ @cli.options = @cli.options.merge("number" => 1)
856
+ @cli.favorites
857
+ a_get("/1/favorites.json").
858
+ with(:query => {:count => "1"}).
859
+ should have_been_made
860
+ end
861
+ it "should limit the number of results to 345" do
862
+ @cli.options = @cli.options.merge("number" => 345)
818
863
  @cli.favorites
819
864
  a_get("/1/favorites.json").
820
- with(:query => {:count => "1", :include_entities => "false"}).
865
+ with(:query => {:count => "200"}).
866
+ should have_been_made
867
+ a_get("/1/favorites.json").
868
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
821
869
  should have_been_made
822
870
  end
823
871
  end
824
872
  context "with a user passed" do
825
873
  before do
826
874
  stub_get("/1/favorites/sferik.json").
827
- with(:query => {:count => "20", :include_entities => "false"}).
875
+ with(:query => {:count => "20"}).
828
876
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
829
877
  end
830
878
  it "should request the correct resource" do
831
879
  @cli.favorites("sferik")
832
880
  a_get("/1/favorites/sferik.json").
833
- with(:query => {:count => "20", :include_entities => "false"}).
881
+ with(:query => {:count => "20"}).
834
882
  should have_been_made
835
883
  end
836
884
  context "--id" do
837
885
  before do
838
886
  @cli.options = @cli.options.merge("id" => true)
839
887
  stub_get("/1/favorites/7505382.json").
840
- with(:query => {:count => "20", :include_entities => "false"}).
888
+ with(:query => {:count => "20"}).
841
889
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
842
890
  end
843
891
  it "should request the correct resource" do
844
892
  @cli.favorites("7505382")
845
893
  a_get("/1/favorites/7505382.json").
846
- with(:query => {:count => "20", :include_entities => "false"}).
894
+ with(:query => {:count => "20"}).
847
895
  should have_been_made
848
896
  end
849
897
  end
@@ -857,16 +905,16 @@ ID Posted at Screen name Text
857
905
  context "one user" do
858
906
  it "should request the correct resource" do
859
907
  stub_post("/1/friendships/create.json").
860
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
908
+ with(:body => {:screen_name => "sferik"}).
861
909
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
862
910
  @cli.follow("sferik")
863
911
  a_post("/1/friendships/create.json").
864
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
912
+ with(:body => {:screen_name => "sferik"}).
865
913
  should have_been_made
866
914
  end
867
915
  it "should have the correct output" do
868
916
  stub_post("/1/friendships/create.json").
869
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
917
+ with(:body => {:screen_name => "sferik"}).
870
918
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
871
919
  @cli.follow("sferik")
872
920
  $stdout.string.should =~ /^@testcli is now following 1 more user\.$/
@@ -875,26 +923,26 @@ ID Posted at Screen name Text
875
923
  before do
876
924
  @cli.options = @cli.options.merge("id" => true)
877
925
  stub_post("/1/friendships/create.json").
878
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
926
+ with(:body => {:user_id => "7505382"}).
879
927
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
880
928
  end
881
929
  it "should request the correct resource" do
882
930
  @cli.follow("7505382")
883
931
  a_post("/1/friendships/create.json").
884
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
932
+ with(:body => {:user_id => "7505382"}).
885
933
  should have_been_made
886
934
  end
887
935
  end
888
936
  context "Twitter is down" do
889
937
  it "should retry 3 times and then raise an error" do
890
938
  stub_post("/1/friendships/create.json").
891
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
939
+ with(:body => {:screen_name => "sferik"}).
892
940
  to_return(:status => 502)
893
941
  lambda do
894
942
  @cli.follow("sferik")
895
943
  end.should raise_error("Twitter is down or being upgraded.")
896
944
  a_post("/1/friendships/create.json").
897
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
945
+ with(:body => {:screen_name => "sferik"}).
898
946
  should have_been_made.times(3)
899
947
  end
900
948
  end
@@ -907,7 +955,7 @@ ID Posted at Screen name Text
907
955
  with(:query => {:cursor => "-1"}).
908
956
  to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
909
957
  stub_get("/1/users/lookup.json").
910
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
958
+ with(:query => {:user_id => "7505382"}).
911
959
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
912
960
  end
913
961
  it "should request the correct resource" do
@@ -916,7 +964,7 @@ ID Posted at Screen name Text
916
964
  with(:query => {:cursor => "-1"}).
917
965
  should have_been_made
918
966
  a_get("/1/users/lookup.json").
919
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
967
+ with(:query => {:user_id => "7505382"}).
920
968
  should have_been_made
921
969
  end
922
970
  it "should have the correct output" do
@@ -1033,7 +1081,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1033
1081
  with(:query => {:cursor => "-1", :screen_name => "sferik"}).
1034
1082
  should have_been_made
1035
1083
  a_get("/1/users/lookup.json").
1036
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1084
+ with(:query => {:user_id => "7505382"}).
1037
1085
  should have_been_made
1038
1086
  end
1039
1087
  end
@@ -1050,7 +1098,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1050
1098
  with(:query => {:cursor => "-1", :user_id => "7505382"}).
1051
1099
  should have_been_made
1052
1100
  a_get("/1/users/lookup.json").
1053
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1101
+ with(:query => {:user_id => "7505382"}).
1054
1102
  should have_been_made
1055
1103
  end
1056
1104
  end
@@ -1062,7 +1110,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1062
1110
  with(:query => {:cursor => "-1"}).
1063
1111
  to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1064
1112
  stub_get("/1/users/lookup.json").
1065
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1113
+ with(:query => {:user_id => "7505382"}).
1066
1114
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1067
1115
  end
1068
1116
  it "should request the correct resource" do
@@ -1071,7 +1119,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1071
1119
  with(:query => {:cursor => "-1"}).
1072
1120
  should have_been_made
1073
1121
  a_get("/1/users/lookup.json").
1074
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1122
+ with(:query => {:user_id => "7505382"}).
1075
1123
  should have_been_made
1076
1124
  end
1077
1125
  it "should have the correct output" do
@@ -1182,7 +1230,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1182
1230
  with(:query => {:cursor => "-1", :screen_name => "sferik"}).
1183
1231
  to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1184
1232
  stub_get("/1/users/lookup.json").
1185
- with(:query => {:user_id => "213747670,428004849", :include_entities => "false"}).
1233
+ with(:query => {:user_id => "213747670,428004849"}).
1186
1234
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1187
1235
  end
1188
1236
  it "should request the correct resource" do
@@ -1191,7 +1239,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1191
1239
  with(:query => {:cursor => "-1", :screen_name => "sferik"}).
1192
1240
  should have_been_made
1193
1241
  a_get("/1/users/lookup.json").
1194
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1242
+ with(:query => {:user_id => "7505382"}).
1195
1243
  should have_been_made
1196
1244
  end
1197
1245
  context "--id" do
@@ -1207,7 +1255,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1207
1255
  with(:query => {:cursor => "-1", :user_id => "7505382"}).
1208
1256
  should have_been_made
1209
1257
  a_get("/1/users/lookup.json").
1210
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1258
+ with(:query => {:user_id => "7505382"}).
1211
1259
  should have_been_made
1212
1260
  end
1213
1261
  end
@@ -1223,7 +1271,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1223
1271
  with(:query => {:cursor => "-1"}).
1224
1272
  to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1225
1273
  stub_get("/1/users/lookup.json").
1226
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1274
+ with(:query => {:user_id => "7505382"}).
1227
1275
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1228
1276
  end
1229
1277
  it "should request the correct resource" do
@@ -1235,7 +1283,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1235
1283
  with(:query => {:cursor => "-1"}).
1236
1284
  should have_been_made
1237
1285
  a_get("/1/users/lookup.json").
1238
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1286
+ with(:query => {:user_id => "7505382"}).
1239
1287
  should have_been_made
1240
1288
  end
1241
1289
  it "should have the correct output" do
@@ -1358,7 +1406,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1358
1406
  with(:query => {:cursor => "-1", :screen_name => "sferik"}).
1359
1407
  should have_been_made
1360
1408
  a_get("/1/users/lookup.json").
1361
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1409
+ with(:query => {:user_id => "7505382"}).
1362
1410
  should have_been_made
1363
1411
  end
1364
1412
  context "--id" do
@@ -1380,7 +1428,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1380
1428
  with(:query => {:cursor => "-1", :user_id => "7505382"}).
1381
1429
  should have_been_made
1382
1430
  a_get("/1/users/lookup.json").
1383
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1431
+ with(:query => {:user_id => "7505382"}).
1384
1432
  should have_been_made
1385
1433
  end
1386
1434
  end
@@ -1396,7 +1444,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1396
1444
  with(:query => {:cursor => "-1"}).
1397
1445
  to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1398
1446
  stub_get("/1/users/lookup.json").
1399
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1447
+ with(:query => {:user_id => "7505382"}).
1400
1448
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1401
1449
  end
1402
1450
  it "should request the correct resource" do
@@ -1408,7 +1456,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1408
1456
  with(:query => {:cursor => "-1"}).
1409
1457
  should have_been_made
1410
1458
  a_get("/1/users/lookup.json").
1411
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1459
+ with(:query => {:user_id => "7505382"}).
1412
1460
  should have_been_made
1413
1461
  end
1414
1462
  it "should have the correct output" do
@@ -1531,7 +1579,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1531
1579
  with(:query => {:cursor => "-1", :screen_name => "sferik"}).
1532
1580
  should have_been_made
1533
1581
  a_get("/1/users/lookup.json").
1534
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1582
+ with(:query => {:user_id => "7505382"}).
1535
1583
  should have_been_made
1536
1584
  end
1537
1585
  context "--id" do
@@ -1553,7 +1601,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
1553
1601
  with(:query => {:cursor => "-1", :user_id => "7505382"}).
1554
1602
  should have_been_made
1555
1603
  a_get("/1/users/lookup.json").
1556
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
1604
+ with(:query => {:user_id => "7505382"}).
1557
1605
  should have_been_made
1558
1606
  end
1559
1607
  end
@@ -1688,13 +1736,13 @@ ID Created at Screen name Slug Members Subscribers ...
1688
1736
  describe "#mentions" do
1689
1737
  before do
1690
1738
  stub_get("/1/statuses/mentions.json").
1691
- with(:query => {:count => "20", :include_entities => "false"}).
1739
+ with(:query => {:count => "20"}).
1692
1740
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1693
1741
  end
1694
1742
  it "should request the correct resource" do
1695
1743
  @cli.mentions
1696
1744
  a_get("/1/statuses/mentions.json").
1697
- with(:query => {:count => "20", :include_entities => "false"}).
1745
+ with(:query => {:count => "20"}).
1698
1746
  should have_been_made
1699
1747
  end
1700
1748
  it "should have the correct output" do
@@ -1789,15 +1837,31 @@ ID Posted at Screen name Text
1789
1837
  end
1790
1838
  context "--number" do
1791
1839
  before do
1792
- @cli.options = @cli.options.merge("number" => 1)
1793
1840
  stub_get("/1/statuses/mentions.json").
1794
- with(:query => {:count => "1", :include_entities => "false"}).
1841
+ with(:query => {:count => "1"}).
1842
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1843
+ stub_get("/1/statuses/mentions.json").
1844
+ with(:query => {:count => "200"}).
1795
1845
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1846
+ stub_get("/1/statuses/mentions.json").
1847
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
1848
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1796
1849
  end
1797
- it "should limit the number of results" do
1850
+ it "should limit the number of results to 1" do
1851
+ @cli.options = @cli.options.merge("number" => 1)
1798
1852
  @cli.mentions
1799
1853
  a_get("/1/statuses/mentions.json").
1800
- with(:query => {:count => "1", :include_entities => "false"}).
1854
+ with(:query => {:count => "1"}).
1855
+ should have_been_made
1856
+ end
1857
+ it "should limit the number of results to 345" do
1858
+ @cli.options = @cli.options.merge("number" => 345)
1859
+ @cli.mentions
1860
+ a_get("/1/statuses/mentions.json").
1861
+ with(:query => {:count => "200"}).
1862
+ should have_been_made
1863
+ a_get("/1/statuses/mentions.json").
1864
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
1801
1865
  should have_been_made
1802
1866
  end
1803
1867
  end
@@ -1816,13 +1880,13 @@ ID Posted at Screen name Text
1816
1880
  before do
1817
1881
  @cli.options = @cli.options.merge("id" => true)
1818
1882
  stub_get("/1/users/show.json").
1819
- with(:query => {:user_id => "420", :include_entities => "false"}).
1883
+ with(:query => {:user_id => "420"}).
1820
1884
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1821
1885
  end
1822
1886
  it "should request the correct resource" do
1823
1887
  @cli.open("420")
1824
1888
  a_get("/1/users/show.json").
1825
- with(:query => {:user_id => "420", :include_entities => "false"}).
1889
+ with(:query => {:user_id => "420"}).
1826
1890
  should have_been_made
1827
1891
  end
1828
1892
  end
@@ -1830,13 +1894,13 @@ ID Posted at Screen name Text
1830
1894
  before do
1831
1895
  @cli.options = @cli.options.merge("status" => true)
1832
1896
  stub_get("/1/statuses/show/55709764298092545.json").
1833
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
1897
+ with(:query => {:include_my_retweet => "false"}).
1834
1898
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1835
1899
  end
1836
1900
  it "should request the correct resource" do
1837
1901
  @cli.open("55709764298092545")
1838
1902
  a_get("/1/statuses/show/55709764298092545.json").
1839
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
1903
+ with(:query => {:include_my_retweet => "false"}).
1840
1904
  should have_been_made
1841
1905
  end
1842
1906
  it "should have the correct output" do
@@ -1851,10 +1915,10 @@ ID Posted at Screen name Text
1851
1915
  before do
1852
1916
  @cli.options = @cli.options.merge("profile" => fixture_path + "/.trc", "location" => true)
1853
1917
  stub_get("/1/statuses/show/55709764298092545.json").
1854
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
1918
+ with(:query => {:include_my_retweet => "false"}).
1855
1919
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1856
1920
  stub_post("/1/statuses/update.json").
1857
- with(:body => {:in_reply_to_status_id => "55709764298092545", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
1921
+ with(:body => {:in_reply_to_status_id => "55709764298092545", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).
1858
1922
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1859
1923
  stub_request(:get, "http://checkip.dyndns.org/").
1860
1924
  to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
@@ -1864,10 +1928,10 @@ ID Posted at Screen name Text
1864
1928
  it "should request the correct resource" do
1865
1929
  @cli.reply("55709764298092545", "Testing")
1866
1930
  a_get("/1/statuses/show/55709764298092545.json").
1867
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
1931
+ with(:query => {:include_my_retweet => "false"}).
1868
1932
  should have_been_made
1869
1933
  a_post("/1/statuses/update.json").
1870
- with(:body => {:in_reply_to_status_id => "55709764298092545", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
1934
+ with(:body => {:in_reply_to_status_id => "55709764298092545", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).
1871
1935
  should have_been_made
1872
1936
  a_request(:get, "http://checkip.dyndns.org/").
1873
1937
  should have_been_made
@@ -1885,10 +1949,10 @@ ID Posted at Screen name Text
1885
1949
  it "should request the correct resource" do
1886
1950
  @cli.reply("55709764298092545", "Testing")
1887
1951
  a_get("/1/statuses/show/55709764298092545.json").
1888
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
1952
+ with(:query => {:include_my_retweet => "false"}).
1889
1953
  should have_been_made
1890
1954
  a_post("/1/statuses/update.json").
1891
- with(:body => {:in_reply_to_status_id => "55709764298092545", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
1955
+ with(:body => {:in_reply_to_status_id => "55709764298092545", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).
1892
1956
  should have_been_made
1893
1957
  a_request(:get, "http://checkip.dyndns.org/").
1894
1958
  should have_been_made
@@ -1906,13 +1970,13 @@ ID Posted at Screen name Text
1906
1970
  before do
1907
1971
  @cli.options = @cli.options.merge("profile" => fixture_path + "/.trc")
1908
1972
  stub_post("/1/report_spam.json").
1909
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
1973
+ with(:body => {:screen_name => "sferik"}).
1910
1974
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1911
1975
  end
1912
1976
  it "should request the correct resource" do
1913
1977
  @cli.report_spam("sferik")
1914
1978
  a_post("/1/report_spam.json").
1915
- with(:body => {:screen_name => "sferik", :include_entities => "false"}).
1979
+ with(:body => {:screen_name => "sferik"}).
1916
1980
  should have_been_made
1917
1981
  end
1918
1982
  it "should have the correct output" do
@@ -1923,13 +1987,13 @@ ID Posted at Screen name Text
1923
1987
  before do
1924
1988
  @cli.options = @cli.options.merge("id" => true)
1925
1989
  stub_post("/1/report_spam.json").
1926
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
1990
+ with(:body => {:user_id => "7505382"}).
1927
1991
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1928
1992
  end
1929
1993
  it "should request the correct resource" do
1930
1994
  @cli.report_spam("7505382")
1931
1995
  a_post("/1/report_spam.json").
1932
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
1996
+ with(:body => {:user_id => "7505382"}).
1933
1997
  should have_been_made
1934
1998
  end
1935
1999
  end
@@ -1955,14 +2019,14 @@ ID Posted at Screen name Text
1955
2019
  describe "#retweets" do
1956
2020
  before do
1957
2021
  stub_get("/1/statuses/retweeted_by_me.json").
1958
- with(:query => {:count => "20", :include_entities => "false"}).
2022
+ with(:query => {:count => "20"}).
1959
2023
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1960
2024
  end
1961
2025
  context "without arguments" do
1962
2026
  it "should request the correct resource" do
1963
2027
  @cli.retweets
1964
2028
  a_get("/1/statuses/retweeted_by_me.json").
1965
- with(:query => {:count => "20", :include_entities => "false"}).
2029
+ with(:query => {:count => "20"}).
1966
2030
  should have_been_made
1967
2031
  end
1968
2032
  it "should have the correct output" do
@@ -2058,41 +2122,57 @@ ID Posted at Screen name Text
2058
2122
  end
2059
2123
  context "--number" do
2060
2124
  before do
2061
- @cli.options = @cli.options.merge("number" => 1)
2062
2125
  stub_get("/1/statuses/retweeted_by_me.json").
2063
- with(:query => {:count => "1", :include_entities => "false"}).
2126
+ with(:query => {:count => "1"}).
2064
2127
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2128
+ stub_get("/1/statuses/retweeted_by_me.json").
2129
+ with(:query => {:count => "200"}).
2130
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2131
+ stub_get("/1/statuses/retweeted_by_me.json").
2132
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
2133
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2065
2134
  end
2066
- it "should limit the number of results" do
2135
+ it "should limit the number of results to 1" do
2136
+ @cli.options = @cli.options.merge("number" => 1)
2137
+ @cli.retweets
2138
+ a_get("/1/statuses/retweeted_by_me.json").
2139
+ with(:query => {:count => "1"}).
2140
+ should have_been_made
2141
+ end
2142
+ it "should limit the number of results to 345" do
2143
+ @cli.options = @cli.options.merge("number" => 345)
2067
2144
  @cli.retweets
2068
2145
  a_get("/1/statuses/retweeted_by_me.json").
2069
- with(:query => {:count => "1", :include_entities => "false"}).
2146
+ with(:query => {:count => "200"}).
2147
+ should have_been_made
2148
+ a_get("/1/statuses/retweeted_by_me.json").
2149
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
2070
2150
  should have_been_made
2071
2151
  end
2072
2152
  end
2073
2153
  context "with a user passed" do
2074
2154
  before do
2075
2155
  stub_get("/1/statuses/retweeted_by_user.json").
2076
- with(:query => {:count => "20", :include_entities => "false", :screen_name => "sferik"}).
2156
+ with(:query => {:count => "20", :screen_name => "sferik"}).
2077
2157
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2078
2158
  end
2079
2159
  it "should request the correct resource" do
2080
2160
  @cli.retweets("sferik")
2081
2161
  a_get("/1/statuses/retweeted_by_user.json").
2082
- with(:query => {:count => "20", :include_entities => "false", :screen_name => "sferik"}).
2162
+ with(:query => {:count => "20", :screen_name => "sferik"}).
2083
2163
  should have_been_made
2084
2164
  end
2085
2165
  context "--id" do
2086
2166
  before do
2087
2167
  @cli.options = @cli.options.merge("id" => true)
2088
2168
  stub_get("/1/statuses/retweeted_by_user.json").
2089
- with(:query => {:count => "20", :include_entities => "false", :user_id => "7505382"}).
2169
+ with(:query => {:count => "20", :user_id => "7505382"}).
2090
2170
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2091
2171
  end
2092
2172
  it "should request the correct resource" do
2093
2173
  @cli.retweets("7505382")
2094
2174
  a_get("/1/statuses/retweeted_by_user.json").
2095
- with(:query => {:count => "20", :include_entities => "false", :user_id => "7505382"}).
2175
+ with(:query => {:count => "20", :user_id => "7505382"}).
2096
2176
  should have_been_made
2097
2177
  end
2098
2178
  end
@@ -2110,13 +2190,13 @@ ID Posted at Screen name Text
2110
2190
  describe "#status" do
2111
2191
  before do
2112
2192
  stub_get("/1/statuses/show/55709764298092545.json").
2113
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
2193
+ with(:query => {:include_my_retweet => "false"}).
2114
2194
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2115
2195
  end
2116
2196
  it "should request the correct resource" do
2117
2197
  @cli.status("55709764298092545")
2118
2198
  a_get("/1/statuses/show/55709764298092545.json").
2119
- with(:query => {:include_entities => "false", :include_my_retweet => "false"}).
2199
+ with(:query => {:include_my_retweet => "false"}).
2120
2200
  should have_been_made
2121
2201
  end
2122
2202
  it "should have the correct output" do
@@ -2150,7 +2230,7 @@ ID,Text,Screen name,Posted at,Location,Retweets,Source,URL
2150
2230
  stub_get("/1/account/verify_credentials.json").
2151
2231
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2152
2232
  stub_get("/1/users/recommendations.json").
2153
- with(:query => {:limit => "20", :include_entities => "false", :screen_name => "sferik"}).
2233
+ with(:query => {:limit => "20", :screen_name => "sferik"}).
2154
2234
  to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2155
2235
  end
2156
2236
  it "should request the correct resource" do
@@ -2158,7 +2238,7 @@ ID,Text,Screen name,Posted at,Location,Retweets,Source,URL
2158
2238
  stub_get("/1/account/verify_credentials.json").
2159
2239
  should have_been_made
2160
2240
  a_get("/1/users/recommendations.json").
2161
- with(:query => {:limit => "20", :include_entities => "false", :screen_name => "sferik"}).
2241
+ with(:query => {:limit => "20", :screen_name => "sferik"}).
2162
2242
  should have_been_made
2163
2243
  end
2164
2244
  it "should have the correct output" do
@@ -2237,13 +2317,13 @@ ID Since Tweets Favorites Listed Following Followers Scre...
2237
2317
  before do
2238
2318
  @cli.options = @cli.options.merge("number" => 1)
2239
2319
  stub_get("/1/users/recommendations.json").
2240
- with(:query => {:limit => "1", :include_entities => "false", :screen_name => "sferik"}).
2320
+ with(:query => {:limit => "1", :screen_name => "sferik"}).
2241
2321
  to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2242
2322
  end
2243
2323
  it "should limit the number of results" do
2244
2324
  @cli.suggest
2245
2325
  a_get("/1/users/recommendations.json").
2246
- with(:query => {:limit => "1", :include_entities => "false", :screen_name => "sferik"}).
2326
+ with(:query => {:limit => "1", :screen_name => "sferik"}).
2247
2327
  should have_been_made
2248
2328
  end
2249
2329
  end
@@ -2287,7 +2367,7 @@ ID Since Tweets Favorites Listed Following Followers Scre...
2287
2367
  it "should request the correct resource" do
2288
2368
  @cli.suggest("sferik")
2289
2369
  a_get("/1/users/recommendations.json").
2290
- with(:query => {:limit => "20", :include_entities => "false", :screen_name => "sferik"}).
2370
+ with(:query => {:limit => "20", :screen_name => "sferik"}).
2291
2371
  should have_been_made
2292
2372
  end
2293
2373
  it "should have the correct output" do
@@ -2298,13 +2378,13 @@ ID Since Tweets Favorites Listed Following Followers Scre...
2298
2378
  before do
2299
2379
  @cli.options = @cli.options.merge("id" => true)
2300
2380
  stub_get("/1/users/recommendations.json").
2301
- with(:query => {:limit => "20", :include_entities => "false", :user_id => "7505382"}).
2381
+ with(:query => {:limit => "20", :user_id => "7505382"}).
2302
2382
  to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2303
2383
  end
2304
2384
  it "should request the correct resource" do
2305
2385
  @cli.suggest("7505382")
2306
2386
  a_get("/1/users/recommendations.json").
2307
- with(:query => {:limit => "20", :include_entities => "false", :user_id => "7505382"}).
2387
+ with(:query => {:limit => "20", :user_id => "7505382"}).
2308
2388
  should have_been_made
2309
2389
  end
2310
2390
  end
@@ -2314,14 +2394,14 @@ ID Since Tweets Favorites Listed Following Followers Scre...
2314
2394
  describe "#timeline" do
2315
2395
  before do
2316
2396
  stub_get("/1/statuses/home_timeline.json").
2317
- with(:query => {:count => "20", :include_entities => "false"}).
2397
+ with(:query => {:count => "20"}).
2318
2398
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2319
2399
  end
2320
2400
  context "without user" do
2321
2401
  it "should request the correct resource" do
2322
2402
  @cli.timeline
2323
2403
  a_get("/1/statuses/home_timeline.json").
2324
- with(:query => {:count => "20", :include_entities => "false"}).
2404
+ with(:query => {:count => "20"}).
2325
2405
  should have_been_made
2326
2406
  end
2327
2407
  it "should have the correct output" do
@@ -2417,41 +2497,87 @@ ID Posted at Screen name Text
2417
2497
  end
2418
2498
  context "--number" do
2419
2499
  before do
2420
- @cli.options = @cli.options.merge("number" => 1)
2421
2500
  stub_get("/1/statuses/home_timeline.json").
2422
- with(:query => {:count => "1", :include_entities => "false"}).
2501
+ with(:query => {:count => "1"}).
2423
2502
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2503
+ stub_get("/1/statuses/home_timeline.json").
2504
+ with(:query => {:count => "200"}).
2505
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2506
+ stub_get("/1/statuses/home_timeline.json").
2507
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
2508
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2424
2509
  end
2425
- it "should limit the number of results" do
2510
+ it "should limit the number of results to 1" do
2511
+ @cli.options = @cli.options.merge("number" => 1)
2426
2512
  @cli.timeline
2427
2513
  a_get("/1/statuses/home_timeline.json").
2428
- with(:query => {:count => "1", :include_entities => "false"}).
2514
+ with(:query => {:count => "1"}).
2515
+ should have_been_made
2516
+ end
2517
+ it "should limit the number of results to 345" do
2518
+ @cli.options = @cli.options.merge("number" => 345)
2519
+ @cli.timeline
2520
+ a_get("/1/statuses/home_timeline.json").
2521
+ with(:query => {:count => "200"}).
2522
+ should have_been_made
2523
+ a_get("/1/statuses/home_timeline.json").
2524
+ with(:query => {:count => "145", :max_id => "194546264212385792"}).
2429
2525
  should have_been_made
2430
2526
  end
2431
2527
  end
2432
2528
  context "with a user passed" do
2433
2529
  before do
2434
2530
  stub_get("/1/statuses/user_timeline.json").
2435
- with(:query => {:count => "20", :include_entities => "false", :screen_name => "sferik"}).
2531
+ with(:query => {:count => "20", :screen_name => "sferik"}).
2436
2532
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2437
2533
  end
2438
2534
  it "should request the correct resource" do
2439
2535
  @cli.timeline("sferik")
2440
2536
  a_get("/1/statuses/user_timeline.json").
2441
- with(:query => {:count => "20", :include_entities => "false", :screen_name => "sferik"}).
2537
+ with(:query => {:count => "20", :screen_name => "sferik"}).
2442
2538
  should have_been_made
2443
2539
  end
2444
2540
  context "--id" do
2445
2541
  before do
2446
2542
  @cli.options = @cli.options.merge("id" => true)
2447
2543
  stub_get("/1/statuses/user_timeline.json").
2448
- with(:query => {:count => "20", :include_entities => "false", :user_id => "7505382"}).
2544
+ with(:query => {:count => "20", :user_id => "7505382"}).
2449
2545
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2450
2546
  end
2451
2547
  it "should request the correct resource" do
2452
2548
  @cli.timeline("7505382")
2453
2549
  a_get("/1/statuses/user_timeline.json").
2454
- with(:query => {:count => "20", :include_entities => "false", :user_id => "7505382"}).
2550
+ with(:query => {:count => "20", :user_id => "7505382"}).
2551
+ should have_been_made
2552
+ end
2553
+ end
2554
+ context "--number" do
2555
+ before do
2556
+ stub_get("/1/statuses/user_timeline.json").
2557
+ with(:query => {:count => "1", :screen_name => "sferik"}).
2558
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2559
+ stub_get("/1/statuses/user_timeline.json").
2560
+ with(:query => {:count => "200", :screen_name => "sferik"}).
2561
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2562
+ stub_get("/1/statuses/user_timeline.json").
2563
+ with(:query => {:count => "145", :screen_name => "sferik", :max_id => "194546264212385792"}).
2564
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2565
+ end
2566
+ it "should limit the number of results to 1" do
2567
+ @cli.options = @cli.options.merge("number" => 1)
2568
+ @cli.timeline("sferik")
2569
+ a_get("/1/statuses/user_timeline.json").
2570
+ with(:query => {:count => "1", :screen_name => "sferik"}).
2571
+ should have_been_made
2572
+ end
2573
+ it "should limit the number of results to 345" do
2574
+ @cli.options = @cli.options.merge("number" => 345)
2575
+ @cli.timeline("sferik")
2576
+ a_get("/1/statuses/user_timeline.json").
2577
+ with(:query => {:count => "200", :screen_name => "sferik"}).
2578
+ should have_been_made
2579
+ a_get("/1/statuses/user_timeline.json").
2580
+ with(:query => {:count => "145", :screen_name => "sferik", :max_id => "194546264212385792"}).
2455
2581
  should have_been_made
2456
2582
  end
2457
2583
  end
@@ -2580,16 +2706,16 @@ WOEID Parent ID Type Name Country
2580
2706
  context "one user" do
2581
2707
  it "should request the correct resource" do
2582
2708
  stub_delete("/1/friendships/destroy.json").
2583
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2709
+ with(:query => {:screen_name => "sferik"}).
2584
2710
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2585
2711
  @cli.unfollow("sferik")
2586
2712
  a_delete("/1/friendships/destroy.json").
2587
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2713
+ with(:query => {:screen_name => "sferik"}).
2588
2714
  should have_been_made
2589
2715
  end
2590
2716
  it "should have the correct output" do
2591
2717
  stub_delete("/1/friendships/destroy.json").
2592
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2718
+ with(:query => {:screen_name => "sferik"}).
2593
2719
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2594
2720
  @cli.unfollow("sferik")
2595
2721
  $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
@@ -2598,26 +2724,26 @@ WOEID Parent ID Type Name Country
2598
2724
  before do
2599
2725
  @cli.options = @cli.options.merge("id" => true)
2600
2726
  stub_delete("/1/friendships/destroy.json").
2601
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
2727
+ with(:query => {:user_id => "7505382"}).
2602
2728
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2603
2729
  end
2604
2730
  it "should request the correct resource" do
2605
2731
  @cli.unfollow("7505382")
2606
2732
  a_delete("/1/friendships/destroy.json").
2607
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
2733
+ with(:query => {:user_id => "7505382"}).
2608
2734
  should have_been_made
2609
2735
  end
2610
2736
  end
2611
2737
  context "Twitter is down" do
2612
2738
  it "should retry 3 times and then raise an error" do
2613
2739
  stub_delete("/1/friendships/destroy.json").
2614
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2740
+ with(:query => {:screen_name => "sferik"}).
2615
2741
  to_return(:status => 502)
2616
2742
  lambda do
2617
2743
  @cli.unfollow("sferik")
2618
2744
  end.should raise_error("Twitter is down or being upgraded.")
2619
2745
  a_delete("/1/friendships/destroy.json").
2620
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2746
+ with(:query => {:screen_name => "sferik"}).
2621
2747
  should have_been_made.times(3)
2622
2748
  end
2623
2749
  end
@@ -2628,7 +2754,7 @@ WOEID Parent ID Type Name Country
2628
2754
  before do
2629
2755
  @cli.options = @cli.options.merge("profile" => fixture_path + "/.trc", "location" => true)
2630
2756
  stub_post("/1/statuses/update.json").
2631
- with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
2757
+ with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).
2632
2758
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2633
2759
  stub_request(:get, "http://checkip.dyndns.org/").
2634
2760
  to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
@@ -2638,7 +2764,7 @@ WOEID Parent ID Type Name Country
2638
2764
  it "should request the correct resource" do
2639
2765
  @cli.update("Testing")
2640
2766
  a_post("/1/statuses/update.json").
2641
- with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
2767
+ with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).
2642
2768
  should have_been_made
2643
2769
  a_request(:get, "http://checkip.dyndns.org/").
2644
2770
  should have_been_made
@@ -2654,13 +2780,13 @@ WOEID Parent ID Type Name Country
2654
2780
  describe "#users" do
2655
2781
  before do
2656
2782
  stub_get("/1/users/lookup.json").
2657
- with(:query => {:screen_name => "sferik,pengwynn", :include_entities => "false"}).
2783
+ with(:query => {:screen_name => "sferik,pengwynn"}).
2658
2784
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2659
2785
  end
2660
2786
  it "should request the correct resource" do
2661
2787
  @cli.users("sferik", "pengwynn")
2662
2788
  a_get("/1/users/lookup.json").
2663
- with(:query => {:screen_name => "sferik,pengwynn", :include_entities => "false"}).
2789
+ with(:query => {:screen_name => "sferik,pengwynn"}).
2664
2790
  should have_been_made
2665
2791
  end
2666
2792
  it "should have the correct output" do
@@ -2711,13 +2837,13 @@ ID,Since,Tweets,Favorites,Listed,Following,Followers,Screen name,Name
2711
2837
  before do
2712
2838
  @cli.options = @cli.options.merge("id" => true)
2713
2839
  stub_get("/1/users/lookup.json").
2714
- with(:query => {:user_id => "7505382,14100886", :include_entities => "false"}).
2840
+ with(:query => {:user_id => "7505382,14100886"}).
2715
2841
  to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2716
2842
  end
2717
2843
  it "should request the correct resource" do
2718
2844
  @cli.users("7505382", "14100886")
2719
2845
  a_get("/1/users/lookup.json").
2720
- with(:query => {:user_id => "7505382,14100886", :include_entities => "false"}).
2846
+ with(:query => {:user_id => "7505382,14100886"}).
2721
2847
  should have_been_made
2722
2848
  end
2723
2849
  end
@@ -2791,13 +2917,13 @@ ID Since Tweets Favorites Listed Following Followers Scre...
2791
2917
  describe "#whois" do
2792
2918
  before do
2793
2919
  stub_get("/1/users/show.json").
2794
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2920
+ with(:query => {:screen_name => "sferik"}).
2795
2921
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2796
2922
  end
2797
2923
  it "should request the correct resource" do
2798
2924
  @cli.whois("sferik")
2799
2925
  a_get("/1/users/show.json").
2800
- with(:query => {:screen_name => "sferik", :include_entities => "false"}).
2926
+ with(:query => {:screen_name => "sferik"}).
2801
2927
  should have_been_made
2802
2928
  end
2803
2929
  it "should have the correct output" do
@@ -2834,13 +2960,13 @@ ID,Verified,Name,Screen name,Bio,Location,Following,Last update,Lasted updated a
2834
2960
  before do
2835
2961
  @cli.options = @cli.options.merge("id" => true)
2836
2962
  stub_get("/1/users/show.json").
2837
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
2963
+ with(:query => {:user_id => "7505382"}).
2838
2964
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
2839
2965
  end
2840
2966
  it "should request the correct resource" do
2841
2967
  @cli.whois("7505382")
2842
2968
  a_get("/1/users/show.json").
2843
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
2969
+ with(:query => {:user_id => "7505382"}).
2844
2970
  should have_been_made
2845
2971
  end
2846
2972
  end