t 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,7 @@ describe T::Search do
16
16
  before :each do
17
17
  T::RCFile.instance.path = fixture_path + "/.trc"
18
18
  @search = T::Search.new
19
+ @search.options = @search.options.merge("color" => "always")
19
20
  @old_stderr = $stderr
20
21
  $stderr = StringIO.new
21
22
  @old_stdout = $stdout
@@ -30,7 +31,7 @@ describe T::Search do
30
31
 
31
32
  describe "#all" do
32
33
  before do
33
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "20"}).to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
34
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "20"}).to_return(:body => fixture("search.json"))
34
35
  end
35
36
  it "requests the correct resource" do
36
37
  @search.all("twitter")
@@ -545,6 +546,22 @@ http://t.co/erdKx6HD"
545
546
  eos
546
547
  end
547
548
  end
549
+ context "--decode-urls" do
550
+ before(:each) do
551
+ @search.options = @search.options.merge("decode_urls" => true)
552
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :include_entities => 1, :count => 20}).to_return(:body => fixture("search_with_entities.json"))
553
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :include_entities => 1, :count => 5, :max_id => 264784855672442882}).to_return(:body => fixture("search_with_entities.json"))
554
+ end
555
+ it "requests the correct resource" do
556
+ @search.all("twitter")
557
+ expect(a_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :include_entities => 1, :count => 20})).to have_been_made
558
+ expect(a_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :include_entities => 1, :count => 5, :max_id => 264784855672442882})).to have_been_made
559
+ end
560
+ it "decodes URLs" do
561
+ @search.all("twitter")
562
+ expect($stdout.string).to include "http://semver.org"
563
+ end
564
+ end
548
565
  context "--long" do
549
566
  before do
550
567
  @search.options = @search.options.merge("long" => true)
@@ -656,10 +673,10 @@ ID Posted at Screen name Text
656
673
  end
657
674
  context "--number" do
658
675
  before do
659
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "1"}).to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
660
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "200"}).to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
661
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "103", :max_id => "267024711169503231"}).to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
662
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "5", :max_id => "267024711169503231"}).to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
676
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "1"}).to_return(:body => fixture("search.json"))
677
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "200"}).to_return(:body => fixture("search.json"))
678
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "103", :max_id => "267024711169503231"}).to_return(:body => fixture("search.json"))
679
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "5", :max_id => "267024711169503231"}).to_return(:body => fixture("search.json"))
663
680
  end
664
681
  it "limits the number of results to 1" do
665
682
  @search.options = @search.options.merge("number" => 1)
@@ -674,30 +691,12 @@ ID Posted at Screen name Text
674
691
  expect(a_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => "5", :max_id => "267024711169503231"})).to have_been_made
675
692
  end
676
693
  end
677
- context "--decode_urls" do
678
- before(:each) do
679
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => 20}).to_return(:body => fixture("search_with_entities.json"), :headers => {:content_type => "application/json; charset=utf-8"})
680
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :count => 5, :max_id => 264784855672442882}).to_return(:body => fixture("search_with_entities.json"), :headers => {:content_type => "application/json; charset=utf-8"})
681
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :include_entities => 1, :count => 20}).to_return(:body => fixture("search_with_entities.json"), :headers => {:content_type => "application/json; charset=utf-8"})
682
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter", :include_entities => 1, :count => 5, :max_id => 264784855672442882}).to_return(:body => fixture("search_with_entities.json"), :headers => {:content_type => "application/json; charset=utf-8"})
683
- end
684
- it "does not decode urls without given the explicit option" do
685
- @search.all("twitter")
686
- expect($stdout.string).to include "http://t.co/fwZfnEaA"
687
- end
688
- it "decodes the urls correctly" do
689
- @search.options = @search.options.merge("decode_urls" => true)
690
- @search.all("twitter")
691
- expect($stdout.string).to include "http://semver.org"
692
- end
693
- end
694
-
695
694
  end
696
695
 
697
696
  describe "#favorites" do
698
697
  before do
699
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
700
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
698
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200"}).to_return(:body => fixture("statuses.json"))
699
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
701
700
  end
702
701
  it "requests the correct resource" do
703
702
  @search.favorites("twitter")
@@ -729,6 +728,22 @@ ID,Posted at,Screen name,Text
729
728
  eos
730
729
  end
731
730
  end
731
+ context "--decode-urls" do
732
+ before(:each) do
733
+ @search.options = @search.options.merge("decode_urls" => true)
734
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :include_entities => 1}).to_return(:body => fixture("statuses.json"))
735
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
736
+ end
737
+ it "requests the correct resource" do
738
+ @search.favorites("twitter")
739
+ expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "200", :include_entities => 1})).to have_been_made
740
+ expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937"})).to have_been_made
741
+ end
742
+ it "decodes URLs" do
743
+ @search.favorites("twitter")
744
+ expect($stdout.string).to include "https://twitter.com/sferik/status/243988000076337152"
745
+ end
746
+ end
732
747
  context "--long" do
733
748
  before do
734
749
  @search.options = @search.options.merge("long" => true)
@@ -742,21 +757,6 @@ ID Posted at Screen name Text
742
757
  eos
743
758
  end
744
759
  end
745
- context "--decode_urls" do
746
- before(:each) do
747
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :include_entities => 1}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
748
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
749
- end
750
- it "does not decode urls without given the explicit option" do
751
- @search.favorites("twitter")
752
- expect($stdout.string).to include "https://t.co/I17jUTu2"
753
- end
754
- it "decodes the urls correctly" do
755
- @search.options = @search.options.merge("decode_urls" => true)
756
- @search.favorites("twitter")
757
- expect($stdout.string).to include "https://twitter.com/sferik/status/243988000076337152"
758
- end
759
- end
760
760
  context "Twitter is down" do
761
761
  it "retries 3 times and then raise an error" do
762
762
  stub_get("/1.1/favorites/list.json").with(:query => {:count => "200"}).to_return(:status => 502)
@@ -768,8 +768,8 @@ ID Posted at Screen name Text
768
768
  end
769
769
  context "with a user passed" do
770
770
  before do
771
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
772
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :max_id => "244099460672679937", :screen_name => "sferik"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
771
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"))
772
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :max_id => "244099460672679937", :screen_name => "sferik"}).to_return(:body => fixture("empty_array.json"))
773
773
  end
774
774
  it "requests the correct resource" do
775
775
  @search.favorites("sferik", "twitter")
@@ -791,8 +791,8 @@ ID Posted at Screen name Text
791
791
  context "--id" do
792
792
  before do
793
793
  @search.options = @search.options.merge("id" => true)
794
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :user_id => "7505382"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
795
- stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :max_id => "244099460672679937", :user_id => "7505382"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
794
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :user_id => "7505382"}).to_return(:body => fixture("statuses.json"))
795
+ stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :max_id => "244099460672679937", :user_id => "7505382"}).to_return(:body => fixture("empty_array.json"))
796
796
  end
797
797
  it "requests the correct resource" do
798
798
  @search.favorites("7505382", "twitter")
@@ -817,8 +817,8 @@ ID Posted at Screen name Text
817
817
 
818
818
  describe "#mentions" do
819
819
  before do
820
- stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
821
- stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
820
+ stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200"}).to_return(:body => fixture("statuses.json"))
821
+ stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
822
822
  end
823
823
  it "requests the correct resource" do
824
824
  @search.mentions("twitter")
@@ -850,6 +850,22 @@ ID,Posted at,Screen name,Text
850
850
  eos
851
851
  end
852
852
  end
853
+ context "--decode-urls" do
854
+ before(:each) do
855
+ @search.options = @search.options.merge("decode_urls" => true)
856
+ stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :include_entities => 1}).to_return(:body => fixture("statuses.json"))
857
+ stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
858
+ end
859
+ it "requests the correct resource" do
860
+ @search.mentions("twitter")
861
+ expect(a_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :include_entities => 1})).to have_been_made
862
+ expect(a_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937"})).to have_been_made
863
+ end
864
+ it "decodes URLs" do
865
+ @search.mentions("twitter")
866
+ expect($stdout.string).to include "https://twitter.com/sferik/status/243988000076337152"
867
+ end
868
+ end
853
869
  context "--long" do
854
870
  before do
855
871
  @search.options = @search.options.merge("long" => true)
@@ -863,21 +879,6 @@ ID Posted at Screen name Text
863
879
  eos
864
880
  end
865
881
  end
866
- context "--decode_urls" do
867
- before(:each) do
868
- stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :include_entities => 1}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
869
- stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
870
- end
871
- it "does not decode urls without given the explicit option" do
872
- @search.mentions("twitter")
873
- expect($stdout.string).to include "https://t.co/I17jUTu2"
874
- end
875
- it "decodes the urls correctly" do
876
- @search.options = @search.options.merge("decode_urls" => true)
877
- @search.mentions("twitter")
878
- expect($stdout.string).to include "https://twitter.com/sferik/status/243988000076337152"
879
- end
880
- end
881
882
  context "Twitter is down" do
882
883
  it "retries 3 times and then raise an error" do
883
884
  stub_get("/1.1/statuses/mentions_timeline.json").with(:query => {:count => "200"}).to_return(:status => 502)
@@ -891,8 +892,8 @@ ID Posted at Screen name Text
891
892
 
892
893
  describe "#list" do
893
894
  before do
894
- stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
895
- stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :max_id => "244099460672679937", :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
895
+ stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("statuses.json"))
896
+ stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :max_id => "244099460672679937", :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("empty_array.json"))
896
897
  end
897
898
  it "requests the correct resource" do
898
899
  @search.list("presidents", "twitter")
@@ -924,6 +925,22 @@ ID,Posted at,Screen name,Text
924
925
  eos
925
926
  end
926
927
  end
928
+ context "--decode-urls" do
929
+ before(:each) do
930
+ @search.options = @search.options.merge("decode_urls" => true)
931
+ stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :include_entities => 1, :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("statuses.json"))
932
+ stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937", :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("empty_array.json"))
933
+ end
934
+ it "requests the correct resource" do
935
+ @search.list("presidents", "twitter")
936
+ expect(a_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :include_entities => 1, :owner_screen_name => "testcli", :slug => "presidents"})).to have_been_made
937
+ expect(a_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937", :owner_screen_name => "testcli", :slug => "presidents"})).to have_been_made
938
+ end
939
+ it "decodes URLs" do
940
+ @search.list("presidents", "twitter")
941
+ expect($stdout.string).to include "https://dev.twitter.com/docs/api/post/direct_messages/destroy"
942
+ end
943
+ end
927
944
  context "--long" do
928
945
  before do
929
946
  @search.options = @search.options.merge("long" => true)
@@ -937,21 +954,6 @@ ID Posted at Screen name Text
937
954
  eos
938
955
  end
939
956
  end
940
- context "--decode_urls" do
941
- before(:each) do
942
- stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :include_entities => 1, :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
943
- stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :include_entities => 1, :max_id => "244099460672679937", :owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
944
- end
945
- it "does not decode urls without given the explicit option" do
946
- @search.list("presidents", "twitter")
947
- expect($stdout.string).to include "https://t.co/I17jUTu2"
948
- end
949
- it "decodes the urls correctly" do
950
- @search.options = @search.options.merge("decode_urls" => true)
951
- @search.list("presidents", "twitter")
952
- expect($stdout.string).to include "https://dev.twitter.com/docs/api/post/direct_messages/destroy"
953
- end
954
- end
955
957
  context "with a user passed" do
956
958
  it "requests the correct resource" do
957
959
  @search.list("testcli/presidents", "twitter")
@@ -960,8 +962,8 @@ ID Posted at Screen name Text
960
962
  context "--id" do
961
963
  before do
962
964
  @search.options = @search.options.merge("id" => true)
963
- stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :owner_id => "7505382", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
964
- stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :max_id => "244099460672679937", :owner_id => "7505382", :slug => "presidents"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
965
+ stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :owner_id => "7505382", :slug => "presidents"}).to_return(:body => fixture("statuses.json"))
966
+ stub_get("/1.1/lists/statuses.json").with(:query => {:count => "200", :max_id => "244099460672679937", :owner_id => "7505382", :slug => "presidents"}).to_return(:body => fixture("empty_array.json"))
965
967
  end
966
968
  it "requests the correct resource" do
967
969
  @search.list("7505382/presidents", "twitter")
@@ -983,8 +985,8 @@ ID Posted at Screen name Text
983
985
 
984
986
  describe "#retweets" do
985
987
  before do
986
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
987
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
988
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true"}).to_return(:body => fixture("statuses.json"))
989
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"))
988
990
  end
989
991
  it "requests the correct resource" do
990
992
  @search.retweets("mosaic")
@@ -1011,6 +1013,22 @@ ID,Posted at,Screen name,Text
1011
1013
  eos
1012
1014
  end
1013
1015
  end
1016
+ context "--decode-urls" do
1017
+ before(:each) do
1018
+ @search.options = @search.options.merge("decode_urls" => true)
1019
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_entities => 1, :include_rts => "true"}).to_return(:body => fixture("statuses.json"))
1020
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_entities => 1, :include_rts => "true", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"))
1021
+ end
1022
+ it "requests the correct resource" do
1023
+ @search.retweets("mosaic")
1024
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_entities => 1, :include_rts => "true"})).to have_been_made
1025
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_entities => 1, :include_rts => "true", :max_id => "244102729860009983"})).to have_been_made.times(2)
1026
+ end
1027
+ it "decodes URLs" do
1028
+ @search.retweets("mosaic")
1029
+ expect($stdout.string).to include "http://heymosaic.com/i/1Z8ssK"
1030
+ end
1031
+ end
1014
1032
  context "--long" do
1015
1033
  before do
1016
1034
  @search.options = @search.options.merge("long" => true)
@@ -1023,21 +1041,6 @@ ID Posted at Screen name Text
1023
1041
  eos
1024
1042
  end
1025
1043
  end
1026
- context "--decode_urls" do
1027
- before(:each) do
1028
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_entities => 1, :include_rts => "true"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1029
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_entities => 1, :include_rts => "true", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1030
- end
1031
- it "does not decode urls without given the explicit option" do
1032
- @search.retweets("mosaic")
1033
- expect($stdout.string).to include "http://t.co/A8013C9k"
1034
- end
1035
- it "decodes the urls correctly" do
1036
- @search.options = @search.options.merge("decode_urls" => true)
1037
- @search.retweets("mosaic")
1038
- expect($stdout.string).to include "http://heymosaic.com/i/1Z8ssK"
1039
- end
1040
- end
1041
1044
  context "Twitter is down" do
1042
1045
  it "retries 3 times and then raise an error" do
1043
1046
  stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true"}).to_return(:status => 502)
@@ -1049,8 +1052,8 @@ ID Posted at Screen name Text
1049
1052
  end
1050
1053
  context "with a user passed" do
1051
1054
  before do
1052
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1053
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :screen_name => "sferik", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1055
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"))
1056
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :screen_name => "sferik", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"))
1054
1057
  end
1055
1058
  it "requests the correct resource" do
1056
1059
  @search.retweets("sferik", "mosaic")
@@ -1068,8 +1071,8 @@ ID Posted at Screen name Text
1068
1071
  context "--id" do
1069
1072
  before do
1070
1073
  @search.options = @search.options.merge("id" => true)
1071
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :user_id => "7505382"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1072
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :user_id => "7505382", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1074
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :user_id => "7505382"}).to_return(:body => fixture("statuses.json"))
1075
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :include_rts => "true", :user_id => "7505382", :max_id => "244102729860009983"}).to_return(:body => fixture("empty_array.json"))
1073
1076
  end
1074
1077
  it "requests the correct resource" do
1075
1078
  @search.retweets("7505382", "mosaic")
@@ -1090,8 +1093,8 @@ ID Posted at Screen name Text
1090
1093
 
1091
1094
  describe "#timeline" do
1092
1095
  before do
1093
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1094
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1096
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200"}).to_return(:body => fixture("statuses.json"))
1097
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
1095
1098
  end
1096
1099
  it "requests the correct resource" do
1097
1100
  @search.timeline("twitter")
@@ -1123,11 +1126,27 @@ ID,Posted at,Screen name,Text
1123
1126
  eos
1124
1127
  end
1125
1128
  end
1129
+ context "--decode-urls" do
1130
+ before(:each) do
1131
+ @search.options = @search.options.merge("decode_urls" => true)
1132
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_entities => 1}).to_return(:body => fixture("statuses.json"))
1133
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :include_entities => 1}).to_return(:body => fixture("empty_array.json"))
1134
+ end
1135
+ it "requests the correct resource" do
1136
+ @search.timeline("twitter")
1137
+ expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_entities => 1})).to have_been_made
1138
+ expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :include_entities => 1})).to have_been_made
1139
+ end
1140
+ it "decodes URLs" do
1141
+ @search.timeline("twitter")
1142
+ expect($stdout.string).to include "https://dev.twitter.com/docs/api/post/direct_messages/destroy"
1143
+ end
1144
+ end
1126
1145
  context "--exclude=replies" do
1127
1146
  before do
1128
1147
  @search.options = @search.options.merge("exclude" => "replies")
1129
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :exclude_replies => "true"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1130
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :exclude_replies => "true", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1148
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :exclude_replies => "true"}).to_return(:body => fixture("statuses.json"))
1149
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :exclude_replies => "true", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
1131
1150
  end
1132
1151
  it "excludes replies" do
1133
1152
  @search.timeline
@@ -1138,8 +1157,8 @@ ID,Posted at,Screen name,Text
1138
1157
  context "--exclude=retweets" do
1139
1158
  before do
1140
1159
  @search.options = @search.options.merge("exclude" => "retweets")
1141
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_rts => "false"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1142
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_rts => "false", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1160
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_rts => "false"}).to_return(:body => fixture("statuses.json"))
1161
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_rts => "false", :max_id => "244099460672679937"}).to_return(:body => fixture("empty_array.json"))
1143
1162
  end
1144
1163
  it "excludes retweets" do
1145
1164
  @search.timeline
@@ -1160,19 +1179,16 @@ ID Posted at Screen name Text
1160
1179
  eos
1161
1180
  end
1162
1181
  end
1163
- context "--decode_urls" do
1164
- before(:each) do
1165
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :include_entities => 1}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1166
- stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :include_entities => 1}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1167
- end
1168
- it "does not decode urls without given the explicit option" do
1169
- @search.timeline("twitter")
1170
- expect($stdout.string).to include "https://t.co/I17jUTu2"
1182
+ context "--since-id" do
1183
+ before do
1184
+ @search.options = @search.options.merge("since_id" => 244104558433951744)
1185
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :since_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
1186
+ stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :since_id => "244104558433951744"}).to_return(:body => fixture("empty_array.json"))
1171
1187
  end
1172
- it "decodes the urls correctly" do
1173
- @search.options = @search.options.merge("decode_urls" => true)
1188
+ it "requests the correct resource" do
1174
1189
  @search.timeline("twitter")
1175
- expect($stdout.string).to include "https://dev.twitter.com/docs/api/post/direct_messages/destroy"
1190
+ expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :since_id => "244104558433951744"})).to have_been_made
1191
+ expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :since_id => "244104558433951744"})).to have_been_made
1176
1192
  end
1177
1193
  end
1178
1194
  context "Twitter is down" do
@@ -1186,8 +1202,8 @@ ID Posted at Screen name Text
1186
1202
  end
1187
1203
  context "with a user passed" do
1188
1204
  before do
1189
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1190
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :screen_name => "sferik"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1205
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"))
1206
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :screen_name => "sferik"}).to_return(:body => fixture("empty_array.json"))
1191
1207
  end
1192
1208
  it "requests the correct resource" do
1193
1209
  @search.timeline("sferik", "twitter")
@@ -1222,8 +1238,8 @@ ID,Posted at,Screen name,Text
1222
1238
  context "--id" do
1223
1239
  before do
1224
1240
  @search.options = @search.options.merge("id" => true)
1225
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :user_id => "7505382"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1226
- stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :user_id => "7505382"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1241
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :user_id => "7505382"}).to_return(:body => fixture("statuses.json"))
1242
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :max_id => "244099460672679937", :user_id => "7505382"}).to_return(:body => fixture("empty_array.json"))
1227
1243
  end
1228
1244
  it "requests the correct resource" do
1229
1245
  @search.timeline("7505382", "twitter")
@@ -1244,6 +1260,18 @@ ID Posted at Screen name Text
1244
1260
  eos
1245
1261
  end
1246
1262
  end
1263
+ context "--since-id" do
1264
+ before do
1265
+ @search.options = @search.options.merge("since_id" => 244104558433951744)
1266
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :screen_name => "sferik", :since_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
1267
+ stub_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :screen_name => "sferik", :max_id => "244099460672679937", :since_id => "244104558433951744"}).to_return(:body => fixture("empty_array.json"))
1268
+ end
1269
+ it "requests the correct resource" do
1270
+ @search.timeline("sferik", "twitter")
1271
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :screen_name => "sferik", :since_id => "244104558433951744"})).to have_been_made
1272
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:count => "200", :screen_name => "sferik", :max_id => "244099460672679937", :since_id => "244104558433951744"})).to have_been_made
1273
+ end
1274
+ end
1247
1275
  context "Twitter is down" do
1248
1276
  it "retries 3 times and then raise an error" do
1249
1277
  stub_get("/1.1/statuses/user_timeline.json").with(:query => {:screen_name => "sferik", :count => "200"}).to_return(:status => 502)
@@ -1258,8 +1286,8 @@ ID Posted at Screen name Text
1258
1286
 
1259
1287
  describe "#users" do
1260
1288
  before do
1261
- stub_get("/1.1/users/search.json").with(:query => {:page => "1", :q => "Erik"}).to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1262
- stub_get("/1.1/users/search.json").with(:query => {:page => "2", :q => "Erik"}).to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1289
+ stub_get("/1.1/users/search.json").with(:query => {:page => "1", :q => "Erik"}).to_return(:body => fixture("users.json"))
1290
+ stub_get("/1.1/users/search.json").with(:query => {:page => "2", :q => "Erik"}).to_return(:body => fixture("empty_array.json"))
1263
1291
  end
1264
1292
  it "requests the correct resource" do
1265
1293
  @search.users("Erik")