t 1.7.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/README.md +21 -8
- data/lib/t.rb +1 -1
- data/lib/t/cli.rb +62 -73
- data/lib/t/collectable.rb +2 -10
- data/lib/t/core_ext/kernel.rb +4 -4
- data/lib/t/delete.rb +4 -4
- data/lib/t/editor.rb +35 -0
- data/lib/t/list.rb +3 -6
- data/lib/t/printable.rb +7 -13
- data/lib/t/requestable.rb +6 -21
- data/lib/t/search.rb +16 -17
- data/lib/t/set.rb +4 -4
- data/lib/t/stream.rb +15 -27
- data/lib/t/utils.rb +10 -10
- data/lib/t/version.rb +3 -3
- data/spec/cli_spec.rb +223 -109
- data/spec/delete_spec.rb +26 -26
- data/spec/editor_spec.rb +102 -0
- data/spec/fixtures/bearer_token.json +1 -0
- data/spec/fixtures/status.json +1 -1
- data/spec/fixtures/status_no_attributes.json +1 -1
- data/spec/fixtures/status_no_country.json +1 -1
- data/spec/fixtures/status_no_full_name.json +1 -1
- data/spec/fixtures/status_no_locality.json +1 -1
- data/spec/fixtures/status_no_place.json +1 -1
- data/spec/fixtures/status_no_street_address.json +1 -1
- data/spec/helper.rb +6 -2
- data/spec/list_spec.rb +3 -3
- data/spec/rcfile_spec.rb +20 -6
- data/spec/search_spec.rb +19 -19
- data/spec/set_spec.rb +4 -4
- data/spec/stream_spec.rb +77 -101
- data/t.gemspec +4 -5
- metadata +11 -57
- metadata.gz.sig +0 -0
- data/spec/fixtures/activity_summary.json +0 -1
data/lib/t/utils.rb
CHANGED
@@ -50,7 +50,7 @@ module T
|
|
50
50
|
def fetch_users(users, options, &block)
|
51
51
|
format_users!(users, options)
|
52
52
|
require 'retryable'
|
53
|
-
users = retryable(:tries => 3, :on => Twitter::Error
|
53
|
+
users = retryable(:tries => 3, :on => Twitter::Error, :sleep => 0) do
|
54
54
|
yield users
|
55
55
|
end
|
56
56
|
[users, users.length]
|
@@ -95,26 +95,26 @@ module T
|
|
95
95
|
"#{count || 0} " + ((count == 1 || count =~ /^1(\.0+)?$/) ? singular : (plural || "#{singular}s"))
|
96
96
|
end
|
97
97
|
|
98
|
-
def decode_full_text(tweet,
|
98
|
+
def decode_full_text(tweet, decode_full_uris = false)
|
99
99
|
require 'htmlentities'
|
100
100
|
text = HTMLEntities.new.decode(tweet.full_text)
|
101
|
-
text =
|
101
|
+
text = decode_uris(text, tweet.uris) if decode_full_uris
|
102
102
|
text
|
103
103
|
end
|
104
104
|
|
105
|
-
def
|
106
|
-
return full_text if
|
105
|
+
def decode_uris(full_text, uri_entities)
|
106
|
+
return full_text if uri_entities.nil?
|
107
107
|
|
108
|
-
|
109
|
-
full_text = full_text.gsub(
|
108
|
+
uri_entities.each do |uri_entity|
|
109
|
+
full_text = full_text.gsub(uri_entity.uri.to_s, uri_entity.expanded_uri.to_s)
|
110
110
|
end
|
111
111
|
|
112
112
|
full_text
|
113
113
|
end
|
114
114
|
|
115
|
-
def open_or_print(
|
116
|
-
Launchy.open(
|
117
|
-
say "Open: #{
|
115
|
+
def open_or_print(uri, options)
|
116
|
+
Launchy.open(uri, options) do
|
117
|
+
say "Open: #{uri}"
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
data/lib/t/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -44,22 +44,22 @@ testcli
|
|
44
44
|
|
45
45
|
describe "#authorize" do
|
46
46
|
before do
|
47
|
-
@cli.options = @cli.options.merge("profile" => project_path + "/tmp/authorize", "display-
|
47
|
+
@cli.options = @cli.options.merge("profile" => project_path + "/tmp/authorize", "display-uri" => true)
|
48
48
|
stub_post("/oauth/request_token").to_return(:body => fixture("request_token"))
|
49
49
|
stub_post("/oauth/access_token").to_return(:body => fixture("access_token"))
|
50
50
|
stub_get("/1.1/account/verify_credentials.json").with(:query => {:include_entities => "false", :skip_status => "true"}).to_return(:body => fixture("sferik.json"))
|
51
51
|
end
|
52
52
|
it "requests the correct resource" do
|
53
|
-
$stdout.
|
54
|
-
$stdin.
|
55
|
-
$stdout.
|
56
|
-
$stdin.
|
57
|
-
$stdout.
|
58
|
-
$stdin.
|
59
|
-
$stdout.
|
60
|
-
$stdin.
|
61
|
-
$stdout.
|
62
|
-
$stdin.
|
53
|
+
expect($stdout).to receive(:print)
|
54
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
55
|
+
expect($stdout).to receive(:print).with("Enter your consumer key: ")
|
56
|
+
expect($stdin).to receive(:gets).and_return("abc123")
|
57
|
+
expect($stdout).to receive(:print).with("Enter your consumer secret: ")
|
58
|
+
expect($stdin).to receive(:gets).and_return("asdfasd223sd2")
|
59
|
+
expect($stdout).to receive(:print).with("Press [Enter] to open the Twitter app authorization page. ")
|
60
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
61
|
+
expect($stdout).to receive(:print).with("Enter the supplied PIN: ")
|
62
|
+
expect($stdin).to receive(:gets).and_return("1234567890")
|
63
63
|
@cli.authorize
|
64
64
|
expect(a_post("/oauth/request_token")).to have_been_made
|
65
65
|
expect(a_post("/oauth/access_token")).to have_been_made
|
@@ -67,37 +67,37 @@ testcli
|
|
67
67
|
end
|
68
68
|
it "does not raise error" do
|
69
69
|
expect do
|
70
|
-
$stdout.
|
71
|
-
$stdin.
|
72
|
-
$stdout.
|
73
|
-
$stdin.
|
74
|
-
$stdout.
|
75
|
-
$stdin.
|
76
|
-
$stdout.
|
77
|
-
$stdin.
|
78
|
-
$stdout.
|
79
|
-
$stdin.
|
70
|
+
expect($stdout).to receive(:print)
|
71
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
72
|
+
expect($stdout).to receive(:print).with("Enter your consumer key: ")
|
73
|
+
expect($stdin).to receive(:gets).and_return("abc123")
|
74
|
+
expect($stdout).to receive(:print).with("Enter your consumer secret: ")
|
75
|
+
expect($stdin).to receive(:gets).and_return("asdfasd223sd2")
|
76
|
+
expect($stdout).to receive(:print).with("Press [Enter] to open the Twitter app authorization page. ")
|
77
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
78
|
+
expect($stdout).to receive(:print).with("Enter the supplied PIN: ")
|
79
|
+
expect($stdin).to receive(:gets).and_return("1234567890")
|
80
80
|
@cli.authorize
|
81
81
|
end.not_to raise_error
|
82
82
|
end
|
83
83
|
context "empty RC file" do
|
84
84
|
before do
|
85
|
-
@cli.options = @cli.options.merge("profile" => project_path + "/tmp/empty", "display-
|
85
|
+
@cli.options = @cli.options.merge("profile" => project_path + "/tmp/empty", "display-uri" => true)
|
86
86
|
end
|
87
87
|
after do
|
88
88
|
File.delete(project_path + "/tmp/empty")
|
89
89
|
end
|
90
90
|
it "requests the correct resource" do
|
91
|
-
$stdout.
|
92
|
-
$stdin.
|
93
|
-
$stdout.
|
94
|
-
$stdin.
|
95
|
-
$stdout.
|
96
|
-
$stdin.
|
97
|
-
$stdout.
|
98
|
-
$stdin.
|
99
|
-
$stdout.
|
100
|
-
$stdin.
|
91
|
+
expect($stdout).to receive(:print)
|
92
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
93
|
+
expect($stdout).to receive(:print).with("Enter your consumer key: ")
|
94
|
+
expect($stdin).to receive(:gets).and_return("abc123")
|
95
|
+
expect($stdout).to receive(:print).with("Enter your consumer secret: ")
|
96
|
+
expect($stdin).to receive(:gets).and_return("asdfasd223sd2")
|
97
|
+
expect($stdout).to receive(:print).with("Press [Enter] to open the Twitter app authorization page. ")
|
98
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
99
|
+
expect($stdout).to receive(:print).with("Enter the supplied PIN: ")
|
100
|
+
expect($stdin).to receive(:gets).and_return("1234567890")
|
101
101
|
@cli.authorize
|
102
102
|
expect(a_post("/oauth/request_token")).to have_been_made
|
103
103
|
expect(a_post("/oauth/access_token")).to have_been_made
|
@@ -105,16 +105,16 @@ testcli
|
|
105
105
|
end
|
106
106
|
it "does not raise error" do
|
107
107
|
expect do
|
108
|
-
$stdout.
|
109
|
-
$stdin.
|
110
|
-
$stdout.
|
111
|
-
$stdin.
|
112
|
-
$stdout.
|
113
|
-
$stdin.
|
114
|
-
$stdout.
|
115
|
-
$stdin.
|
116
|
-
$stdout.
|
117
|
-
$stdin.
|
108
|
+
expect($stdout).to receive(:print)
|
109
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
110
|
+
expect($stdout).to receive(:print).with("Enter your consumer key: ")
|
111
|
+
expect($stdin).to receive(:gets).and_return("abc123")
|
112
|
+
expect($stdout).to receive(:print).with("Enter your consumer secret: ")
|
113
|
+
expect($stdin).to receive(:gets).and_return("asdfasd223sd2")
|
114
|
+
expect($stdout).to receive(:print).with("Press [Enter] to open the Twitter app authorization page. ")
|
115
|
+
expect($stdin).to receive(:gets).and_return("\n")
|
116
|
+
expect($stdout).to receive(:print).with("Enter the supplied PIN: ")
|
117
|
+
expect($stdin).to receive(:gets).and_return("1234567890")
|
118
118
|
@cli.authorize
|
119
119
|
end.not_to raise_error
|
120
120
|
end
|
@@ -970,6 +970,16 @@ ID Posted at Screen name Text
|
|
970
970
|
end
|
971
971
|
end
|
972
972
|
end
|
973
|
+
context "--max-id" do
|
974
|
+
before do
|
975
|
+
@cli.options = @cli.options.merge("max_id" => 244104558433951744)
|
976
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "20", :max_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
|
977
|
+
end
|
978
|
+
it "requests the correct resource" do
|
979
|
+
@cli.favorites
|
980
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "20", :max_id => "244104558433951744"})).to have_been_made
|
981
|
+
end
|
982
|
+
end
|
973
983
|
context "--number" do
|
974
984
|
before do
|
975
985
|
stub_get("/1.1/favorites/list.json").with(:query => {:count => "1"}).to_return(:body => fixture("statuses.json"))
|
@@ -988,6 +998,16 @@ ID Posted at Screen name Text
|
|
988
998
|
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "1", :max_id => "265500541700956160"})).to have_been_made
|
989
999
|
end
|
990
1000
|
end
|
1001
|
+
context "--since-id" do
|
1002
|
+
before do
|
1003
|
+
@cli.options = @cli.options.merge("since_id" => 244104558433951744)
|
1004
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "20", :since_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
|
1005
|
+
end
|
1006
|
+
it "requests the correct resource" do
|
1007
|
+
@cli.favorites
|
1008
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "20", :since_id => "244104558433951744"})).to have_been_made
|
1009
|
+
end
|
1010
|
+
end
|
991
1011
|
context "with a user passed" do
|
992
1012
|
before do
|
993
1013
|
stub_get("/1.1/favorites/list.json").with(:query => {:count => "20", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"))
|
@@ -1006,6 +1026,44 @@ ID Posted at Screen name Text
|
|
1006
1026
|
expect(a_get("/1.1/favorites/list.json").with(:query => {:user_id => "7505382", :count => "20"})).to have_been_made
|
1007
1027
|
end
|
1008
1028
|
end
|
1029
|
+
context "--max-id" do
|
1030
|
+
before do
|
1031
|
+
@cli.options = @cli.options.merge("max_id" => 244104558433951744)
|
1032
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "20", :screen_name => "sferik", :max_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
|
1033
|
+
end
|
1034
|
+
it "requests the correct resource" do
|
1035
|
+
@cli.favorites("sferik")
|
1036
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "20", :screen_name => "sferik", :max_id => "244104558433951744"})).to have_been_made
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
context "--number" do
|
1040
|
+
before do
|
1041
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "1", :screen_name => "sferik"}).to_return(:body => fixture("statuses.json"))
|
1042
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "200", :screen_name => "sferik"}).to_return(:body => fixture("200_statuses.json"))
|
1043
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "1", :screen_name => "sferik", :max_id => "265500541700956160"}).to_return(:body => fixture("statuses.json"))
|
1044
|
+
end
|
1045
|
+
it "limits the number of results to 1" do
|
1046
|
+
@cli.options = @cli.options.merge("number" => 1)
|
1047
|
+
@cli.favorites("sferik")
|
1048
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "1", :screen_name => "sferik"})).to have_been_made
|
1049
|
+
end
|
1050
|
+
it "limits the number of results to 201" do
|
1051
|
+
@cli.options = @cli.options.merge("number" => 201)
|
1052
|
+
@cli.favorites("sferik")
|
1053
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "200", :screen_name => "sferik"})).to have_been_made
|
1054
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "1", :screen_name => "sferik", :max_id => "265500541700956160"})).to have_been_made
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
context "--since-id" do
|
1058
|
+
before do
|
1059
|
+
@cli.options = @cli.options.merge("since_id" => 244104558433951744)
|
1060
|
+
stub_get("/1.1/favorites/list.json").with(:query => {:count => "20", :screen_name => "sferik", :since_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
|
1061
|
+
end
|
1062
|
+
it "requests the correct resource" do
|
1063
|
+
@cli.favorites("sferik")
|
1064
|
+
expect(a_get("/1.1/favorites/list.json").with(:query => {:count => "20", :screen_name => "sferik", :since_id => "244104558433951744"})).to have_been_made
|
1065
|
+
end
|
1066
|
+
end
|
1009
1067
|
end
|
1010
1068
|
end
|
1011
1069
|
|
@@ -1052,7 +1110,7 @@ ID Posted at Screen name Text
|
|
1052
1110
|
stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "14100886"}).to_return(:status => 502)
|
1053
1111
|
expect do
|
1054
1112
|
@cli.follow("sferik", "pengwynn")
|
1055
|
-
end.to raise_error(
|
1113
|
+
end.to raise_error(Twitter::Error::BadGateway)
|
1056
1114
|
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made.times(3)
|
1057
1115
|
expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made.times(3)
|
1058
1116
|
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "14100886"})).to have_been_made.times(3)
|
@@ -1976,7 +2034,7 @@ ID Posted at Screen name Text
|
|
1976
2034
|
|
1977
2035
|
describe "#open" do
|
1978
2036
|
before do
|
1979
|
-
@cli.options = @cli.options.merge("display-
|
2037
|
+
@cli.options = @cli.options.merge("display-uri" => true)
|
1980
2038
|
end
|
1981
2039
|
it "has the correct output" do
|
1982
2040
|
expect do
|
@@ -2012,18 +2070,18 @@ ID Posted at Screen name Text
|
|
2012
2070
|
|
2013
2071
|
describe "#reply" do
|
2014
2072
|
before do
|
2015
|
-
@cli.options = @cli.options.merge("profile" => fixture_path + "/.trc", "location" =>
|
2073
|
+
@cli.options = @cli.options.merge("profile" => fixture_path + "/.trc", "location" => nil)
|
2016
2074
|
stub_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"}).to_return(:body => fixture("status_with_mention.json"))
|
2017
|
-
stub_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :
|
2075
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
2018
2076
|
stub_request(:get, "http://checkip.dyndns.org/").to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
|
2019
2077
|
stub_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169").to_return(:body => fixture("geoplugin.xml"), :headers => {:content_type => "application/xml"})
|
2020
2078
|
end
|
2021
2079
|
it "requests the correct resource" do
|
2022
2080
|
@cli.reply("263813522369159169", "Testing")
|
2023
2081
|
expect(a_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"})).to have_been_made
|
2024
|
-
expect(a_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :
|
2025
|
-
expect(a_request(:get, "http://checkip.dyndns.org/")).
|
2026
|
-
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).
|
2082
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :trim_user => "true"})).to have_been_made
|
2083
|
+
expect(a_request(:get, "http://checkip.dyndns.org/")).not_to have_been_made
|
2084
|
+
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).not_to have_been_made
|
2027
2085
|
end
|
2028
2086
|
it "has the correct output" do
|
2029
2087
|
@cli.reply("263813522369159169", "Testing")
|
@@ -2032,21 +2090,56 @@ ID Posted at Screen name Text
|
|
2032
2090
|
context "--all" do
|
2033
2091
|
before do
|
2034
2092
|
@cli.options = @cli.options.merge("all" => true)
|
2035
|
-
stub_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench @sferik Testing", :
|
2093
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench @sferik Testing", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
2094
|
+
end
|
2095
|
+
it "requests the correct resource" do
|
2096
|
+
@cli.reply("263813522369159169", "Testing")
|
2097
|
+
expect(a_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"})).to have_been_made
|
2098
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench @sferik Testing", :trim_user => "true"})).to have_been_made
|
2099
|
+
expect(a_request(:get, "http://checkip.dyndns.org/")).not_to have_been_made
|
2100
|
+
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).not_to have_been_made
|
2101
|
+
end
|
2102
|
+
it "has the correct output" do
|
2103
|
+
@cli.reply("263813522369159169", "Testing")
|
2104
|
+
expect($stdout.string.split("\n").first).to eq "Reply posted by @testcli to @joshfrench @sferik."
|
2105
|
+
end
|
2106
|
+
end
|
2107
|
+
context "--location" do
|
2108
|
+
before do
|
2109
|
+
@cli.options = @cli.options.merge("location" => "location")
|
2110
|
+
stub_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"}).to_return(:body => fixture("status_with_mention.json"))
|
2111
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
2036
2112
|
end
|
2037
2113
|
it "requests the correct resource" do
|
2038
2114
|
@cli.reply("263813522369159169", "Testing")
|
2039
2115
|
expect(a_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"})).to have_been_made
|
2040
|
-
expect(a_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench
|
2116
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"})).to have_been_made
|
2041
2117
|
expect(a_request(:get, "http://checkip.dyndns.org/")).to have_been_made
|
2042
2118
|
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).to have_been_made
|
2043
2119
|
end
|
2044
2120
|
it "has the correct output" do
|
2045
2121
|
@cli.reply("263813522369159169", "Testing")
|
2046
|
-
expect($stdout.string.split("\n").first).to eq "Reply posted by @testcli to @joshfrench
|
2122
|
+
expect($stdout.string.split("\n").first).to eq "Reply posted by @testcli to @joshfrench."
|
2047
2123
|
end
|
2048
2124
|
end
|
2049
|
-
|
2125
|
+
context "--location 'latitude,longitude'" do
|
2126
|
+
before do
|
2127
|
+
@cli.options = @cli.options.merge("location" => "41.03132,28.9869")
|
2128
|
+
stub_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"}).to_return(:body => fixture("status_with_mention.json"))
|
2129
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :lat => "41.03132", :long => "28.9869", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
2130
|
+
end
|
2131
|
+
it "requests the correct resource" do
|
2132
|
+
@cli.reply("263813522369159169", "Testing")
|
2133
|
+
expect(a_get("/1.1/statuses/show/263813522369159169.json").with(:query => {:include_my_retweet => "false"})).to have_been_made
|
2134
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:in_reply_to_status_id => "263813522369159169", :status => "@joshfrench Testing", :lat => "41.03132", :long => "28.9869", :trim_user => "true"})).to have_been_made
|
2135
|
+
expect(a_request(:get, "http://checkip.dyndns.org/")).not_to have_been_made
|
2136
|
+
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).not_to have_been_made
|
2137
|
+
end
|
2138
|
+
it "has the correct output" do
|
2139
|
+
@cli.reply("263813522369159169", "Testing")
|
2140
|
+
expect($stdout.string.split("\n").first).to eq "Reply posted by @testcli to @joshfrench."
|
2141
|
+
end
|
2142
|
+
end end
|
2050
2143
|
|
2051
2144
|
describe "#report_spam" do
|
2052
2145
|
before do
|
@@ -2341,12 +2434,10 @@ ID Posted at Screen name Text
|
|
2341
2434
|
describe "#status" do
|
2342
2435
|
before do
|
2343
2436
|
stub_get("/1.1/statuses/show/55709764298092545.json").with(:query => {:include_my_retweet => "false"}).to_return(:body => fixture("status.json"))
|
2344
|
-
stub_get("/i/statuses/55709764298092545/activity/summary.json").to_return(:body => fixture("activity_summary.json"))
|
2345
2437
|
end
|
2346
2438
|
it "requests the correct resources" do
|
2347
2439
|
@cli.status("55709764298092545")
|
2348
2440
|
expect(a_get("/1.1/statuses/show/55709764298092545.json").with(:query => {:include_my_retweet => "false"})).to have_been_made
|
2349
|
-
expect(a_get("/i/statuses/55709764298092545/activity/summary.json")).to have_been_made
|
2350
2441
|
end
|
2351
2442
|
it "has the correct output" do
|
2352
2443
|
@cli.status("55709764298092545")
|
@@ -2356,8 +2447,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2356
2447
|
Screen name @sferik
|
2357
2448
|
Posted at Apr 6 2011 (8 months ago)
|
2358
2449
|
Retweets 320
|
2359
|
-
Favorites
|
2360
|
-
Replies 1
|
2450
|
+
Favorites 50
|
2361
2451
|
Source Twitter for iPhone
|
2362
2452
|
Location Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, California, United States
|
2363
2453
|
eos
|
@@ -2369,8 +2459,8 @@ Location Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, Californi
|
|
2369
2459
|
it "has the correct output" do
|
2370
2460
|
@cli.status("55709764298092545")
|
2371
2461
|
expect($stdout.string).to eq <<-eos
|
2372
|
-
ID,Posted at,Screen name,Text,Retweets,Favorites,
|
2373
|
-
55709764298092545,2011-04-06 19:13:37 +0000,sferik,The problem with your code is that it's doing exactly what you told it to do.,320,
|
2462
|
+
ID,Posted at,Screen name,Text,Retweets,Favorites,Source,Location
|
2463
|
+
55709764298092545,2011-04-06 19:13:37 +0000,sferik,The problem with your code is that it's doing exactly what you told it to do.,320,50,Twitter for iPhone,"Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, California, United States"
|
2374
2464
|
eos
|
2375
2465
|
end
|
2376
2466
|
end
|
@@ -2386,8 +2476,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2386
2476
|
Screen name @sferik
|
2387
2477
|
Posted at Apr 6 2011 (8 months ago)
|
2388
2478
|
Retweets 320
|
2389
|
-
Favorites
|
2390
|
-
Replies 1
|
2479
|
+
Favorites 50
|
2391
2480
|
Source Twitter for iPhone
|
2392
2481
|
Location Blowfish Sushi To Die For, San Francisco, California, United States
|
2393
2482
|
eos
|
@@ -2405,8 +2494,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2405
2494
|
Screen name @sferik
|
2406
2495
|
Posted at Apr 6 2011 (8 months ago)
|
2407
2496
|
Retweets 320
|
2408
|
-
Favorites
|
2409
|
-
Replies 1
|
2497
|
+
Favorites 50
|
2410
2498
|
Source Twitter for iPhone
|
2411
2499
|
Location Blowfish Sushi To Die For, San Francisco, California, United States
|
2412
2500
|
eos
|
@@ -2424,8 +2512,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2424
2512
|
Screen name @sferik
|
2425
2513
|
Posted at Apr 6 2011 (8 months ago)
|
2426
2514
|
Retweets 320
|
2427
|
-
Favorites
|
2428
|
-
Replies 1
|
2515
|
+
Favorites 50
|
2429
2516
|
Source Twitter for iPhone
|
2430
2517
|
Location Blowfish Sushi To Die For, San Francisco, United States
|
2431
2518
|
eos
|
@@ -2443,8 +2530,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2443
2530
|
Screen name @sferik
|
2444
2531
|
Posted at Apr 6 2011 (8 months ago)
|
2445
2532
|
Retweets 320
|
2446
|
-
Favorites
|
2447
|
-
Replies 1
|
2533
|
+
Favorites 50
|
2448
2534
|
Source Twitter for iPhone
|
2449
2535
|
Location Blowfish Sushi To Die For, San Francisco
|
2450
2536
|
eos
|
@@ -2462,8 +2548,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2462
2548
|
Screen name @sferik
|
2463
2549
|
Posted at Apr 6 2011 (8 months ago)
|
2464
2550
|
Retweets 320
|
2465
|
-
Favorites
|
2466
|
-
Replies 1
|
2551
|
+
Favorites 50
|
2467
2552
|
Source Twitter for iPhone
|
2468
2553
|
Location Blowfish Sushi To Die For
|
2469
2554
|
eos
|
@@ -2482,8 +2567,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2482
2567
|
Screen name @sferik
|
2483
2568
|
Posted at Apr 6 2011 (8 months ago)
|
2484
2569
|
Retweets 320
|
2485
|
-
Favorites
|
2486
|
-
Replies 1
|
2570
|
+
Favorites 50
|
2487
2571
|
Source Twitter for iPhone
|
2488
2572
|
Location San Francisco, CA, USA
|
2489
2573
|
eos
|
@@ -2501,8 +2585,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2501
2585
|
Screen name @sferik
|
2502
2586
|
Posted at Apr 6 2011 (8 months ago)
|
2503
2587
|
Retweets 320
|
2504
|
-
Favorites
|
2505
|
-
Replies 1
|
2588
|
+
Favorites 50
|
2506
2589
|
Source Twitter for iPhone
|
2507
2590
|
Location CA, USA
|
2508
2591
|
eos
|
@@ -2521,8 +2604,7 @@ Text The problem with your code is that it's doing exactly what you told
|
|
2521
2604
|
Screen name @sferik
|
2522
2605
|
Posted at Apr 6 2011 (8 months ago)
|
2523
2606
|
Retweets 320
|
2524
|
-
Favorites
|
2525
|
-
Replies 1
|
2607
|
+
Favorites 50
|
2526
2608
|
Source Twitter for iPhone
|
2527
2609
|
Location USA
|
2528
2610
|
eos
|
@@ -2714,34 +2796,6 @@ ID Posted at Screen name Text
|
|
2714
2796
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
|
2715
2797
|
eos
|
2716
2798
|
end
|
2717
|
-
context "--max-id" do
|
2718
|
-
before do
|
2719
|
-
@cli.options = @cli.options.merge("max_id" => 244104558433951744)
|
2720
|
-
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "20", :max_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
|
2721
|
-
end
|
2722
|
-
it "requests the correct resource" do
|
2723
|
-
@cli.timeline
|
2724
|
-
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "20", :max_id => "244104558433951744"})).to have_been_made
|
2725
|
-
end
|
2726
|
-
end
|
2727
|
-
context "--number" do
|
2728
|
-
before do
|
2729
|
-
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1"}).to_return(:body => fixture("statuses.json"))
|
2730
|
-
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200"}).to_return(:body => fixture("200_statuses.json"))
|
2731
|
-
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1", :max_id => "265500541700956160"}).to_return(:body => fixture("statuses.json"))
|
2732
|
-
end
|
2733
|
-
it "limits the number of results to 1" do
|
2734
|
-
@cli.options = @cli.options.merge("number" => 1)
|
2735
|
-
@cli.timeline
|
2736
|
-
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1"})).to have_been_made
|
2737
|
-
end
|
2738
|
-
it "limits the number of results to 201" do
|
2739
|
-
@cli.options = @cli.options.merge("number" => 201)
|
2740
|
-
@cli.timeline
|
2741
|
-
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200"})).to have_been_made
|
2742
|
-
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1", :max_id => "265500541700956160"})).to have_been_made
|
2743
|
-
end
|
2744
|
-
end
|
2745
2799
|
context "--reverse" do
|
2746
2800
|
before do
|
2747
2801
|
@cli.options = @cli.options.merge("reverse" => true)
|
@@ -2774,6 +2828,34 @@ ID Posted at Screen name Text
|
|
2774
2828
|
end
|
2775
2829
|
end
|
2776
2830
|
end
|
2831
|
+
context "--max-id" do
|
2832
|
+
before do
|
2833
|
+
@cli.options = @cli.options.merge("max_id" => 244104558433951744)
|
2834
|
+
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "20", :max_id => "244104558433951744"}).to_return(:body => fixture("statuses.json"))
|
2835
|
+
end
|
2836
|
+
it "requests the correct resource" do
|
2837
|
+
@cli.timeline
|
2838
|
+
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "20", :max_id => "244104558433951744"})).to have_been_made
|
2839
|
+
end
|
2840
|
+
end
|
2841
|
+
context "--number" do
|
2842
|
+
before do
|
2843
|
+
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1"}).to_return(:body => fixture("statuses.json"))
|
2844
|
+
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200"}).to_return(:body => fixture("200_statuses.json"))
|
2845
|
+
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1", :max_id => "265500541700956160"}).to_return(:body => fixture("statuses.json"))
|
2846
|
+
end
|
2847
|
+
it "limits the number of results to 1" do
|
2848
|
+
@cli.options = @cli.options.merge("number" => 1)
|
2849
|
+
@cli.timeline
|
2850
|
+
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1"})).to have_been_made
|
2851
|
+
end
|
2852
|
+
it "limits the number of results to 201" do
|
2853
|
+
@cli.options = @cli.options.merge("number" => 201)
|
2854
|
+
@cli.timeline
|
2855
|
+
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "200"})).to have_been_made
|
2856
|
+
expect(a_get("/1.1/statuses/home_timeline.json").with(:query => {:count => "1", :max_id => "265500541700956160"})).to have_been_made
|
2857
|
+
end
|
2858
|
+
end
|
2777
2859
|
context "--since-id" do
|
2778
2860
|
before do
|
2779
2861
|
@cli.options = @cli.options.merge("since_id" => 244104558433951744)
|
@@ -3014,7 +3096,7 @@ WOEID Parent ID Type Name Country
|
|
3014
3096
|
stub_post("/1.1/friendships/destroy.json").with(:body => {:screen_name => "sferik"}).to_return(:status => 502)
|
3015
3097
|
expect do
|
3016
3098
|
@cli.unfollow("sferik")
|
3017
|
-
end.to raise_error(
|
3099
|
+
end.to raise_error(Twitter::Error::BadGateway)
|
3018
3100
|
expect(a_post("/1.1/friendships/destroy.json").with(:body => {:screen_name => "sferik"})).to have_been_made.times(3)
|
3019
3101
|
end
|
3020
3102
|
end
|
@@ -3023,16 +3105,16 @@ WOEID Parent ID Type Name Country
|
|
3023
3105
|
|
3024
3106
|
describe "#update" do
|
3025
3107
|
before do
|
3026
|
-
@cli.options = @cli.options.merge("profile" => fixture_path + "/.trc"
|
3027
|
-
stub_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :
|
3108
|
+
@cli.options = @cli.options.merge("profile" => fixture_path + "/.trc")
|
3109
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
3028
3110
|
stub_request(:get, "http://checkip.dyndns.org/").to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
|
3029
3111
|
stub_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169").to_return(:body => fixture("geoplugin.xml"), :headers => {:content_type => "application/xml"})
|
3030
3112
|
end
|
3031
3113
|
it "requests the correct resource" do
|
3032
3114
|
@cli.update("Testing")
|
3033
|
-
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :
|
3034
|
-
expect(a_request(:get, "http://checkip.dyndns.org/")).
|
3035
|
-
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).
|
3115
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :trim_user => "true"})).to have_been_made
|
3116
|
+
expect(a_request(:get, "http://checkip.dyndns.org/")).not_to have_been_made
|
3117
|
+
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).not_to have_been_made
|
3036
3118
|
end
|
3037
3119
|
it "has the correct output" do
|
3038
3120
|
@cli.update("Testing")
|
@@ -3052,6 +3134,38 @@ WOEID Parent ID Type Name Country
|
|
3052
3134
|
expect($stdout.string.split("\n").first).to eq "Tweet posted by @testcli."
|
3053
3135
|
end
|
3054
3136
|
end
|
3137
|
+
context "--location" do
|
3138
|
+
before do
|
3139
|
+
@cli.options = @cli.options.merge("location" => "location")
|
3140
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
3141
|
+
end
|
3142
|
+
it "requests the correct resource" do
|
3143
|
+
@cli.update("Testing")
|
3144
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :trim_user => "true"})).to have_been_made
|
3145
|
+
expect(a_request(:get, "http://checkip.dyndns.org/")).to have_been_made
|
3146
|
+
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).to have_been_made
|
3147
|
+
end
|
3148
|
+
it "has the correct output" do
|
3149
|
+
@cli.update("Testing")
|
3150
|
+
expect($stdout.string.split("\n").first).to eq "Tweet posted by @testcli."
|
3151
|
+
end
|
3152
|
+
end
|
3153
|
+
context "--location 'latitude,longitude'" do
|
3154
|
+
before do
|
3155
|
+
@cli.options = @cli.options.merge("location" => "41.03132,28.9869")
|
3156
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :lat => "41.03132", :long => "28.9869", :trim_user => "true"}).to_return(:body => fixture("status.json"))
|
3157
|
+
end
|
3158
|
+
it "requests the correct resource" do
|
3159
|
+
@cli.update("Testing")
|
3160
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "Testing", :lat => "41.03132", :long => "28.9869", :trim_user => "true"})).to have_been_made
|
3161
|
+
expect(a_request(:get, "http://checkip.dyndns.org/")).not_to have_been_made
|
3162
|
+
expect(a_request(:get, "http://www.geoplugin.net/xml.gp?ip=50.131.22.169")).not_to have_been_made
|
3163
|
+
end
|
3164
|
+
it "has the correct output" do
|
3165
|
+
@cli.update("Testing")
|
3166
|
+
expect($stdout.string.split("\n").first).to eq "Tweet posted by @testcli."
|
3167
|
+
end
|
3168
|
+
end
|
3055
3169
|
end
|
3056
3170
|
|
3057
3171
|
describe "#users" do
|