t 0.1.0 → 0.2.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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'helper'
3
3
 
4
- describe T::Set do
4
+ describe T::CLI::Set do
5
5
 
6
6
  before do
7
7
  @t = T::CLI.new
@@ -19,15 +19,15 @@ describe T::Set do
19
19
 
20
20
  describe "#bio" do
21
21
  before do
22
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
22
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
23
23
  stub_post("/1/account/update_profile.json").
24
- with(:body => {:description => "A mind forever voyaging through strange seas of thought, alone."}).
24
+ with(:body => {:description => "A mind forever voyaging through strange seas of thought, alone.", :include_entities => "false"}).
25
25
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
26
26
  end
27
27
  it "should request the correct resource" do
28
28
  @t.set("bio", "A mind forever voyaging through strange seas of thought, alone.")
29
29
  a_post("/1/account/update_profile.json").
30
- with(:body => {:description => "A mind forever voyaging through strange seas of thought, alone."}).
30
+ with(:body => {:description => "A mind forever voyaging through strange seas of thought, alone.", :include_entities => "false"}).
31
31
  should have_been_made
32
32
  end
33
33
  it "should have the correct output" do
@@ -36,9 +36,9 @@ describe T::Set do
36
36
  end
37
37
  end
38
38
 
39
- describe "#bio" do
39
+ describe "#default" do
40
40
  before do
41
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
41
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
42
42
  end
43
43
  it "should have the correct output" do
44
44
  @t.set("default", "testcli", "abc123")
@@ -48,7 +48,7 @@ describe T::Set do
48
48
 
49
49
  describe "#language" do
50
50
  before do
51
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
51
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
52
52
  stub_post("/1/account/settings.json").
53
53
  with(:body => {:lang => "en"}).
54
54
  to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
@@ -67,15 +67,15 @@ describe T::Set do
67
67
 
68
68
  describe "#location" do
69
69
  before do
70
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
70
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
71
71
  stub_post("/1/account/update_profile.json").
72
- with(:body => {:location => "San Francisco"}).
72
+ with(:body => {:location => "San Francisco", :include_entities => "false"}).
73
73
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
74
74
  end
75
75
  it "should request the correct resource" do
76
76
  @t.set("location", "San Francisco")
77
77
  a_post("/1/account/update_profile.json").
78
- with(:body => {:location => "San Francisco"}).
78
+ with(:body => {:location => "San Francisco", :include_entities => "false"}).
79
79
  should have_been_made
80
80
  end
81
81
  it "should have the correct output" do
@@ -86,15 +86,15 @@ describe T::Set do
86
86
 
87
87
  describe "#name" do
88
88
  before do
89
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
89
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
90
90
  stub_post("/1/account/update_profile.json").
91
- with(:body => {:name => "Erik Michaels-Ober"}).
91
+ with(:body => {:name => "Erik Michaels-Ober", :include_entities => "false"}).
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
  @t.set("name", "Erik Michaels-Ober")
96
96
  a_post("/1/account/update_profile.json").
97
- with(:body => {:name => "Erik Michaels-Ober"}).
97
+ with(:body => {:name => "Erik Michaels-Ober", :include_entities => "false"}).
98
98
  should have_been_made
99
99
  end
100
100
  it "should have the correct output" do
@@ -105,15 +105,15 @@ describe T::Set do
105
105
 
106
106
  describe "#url" do
107
107
  before do
108
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
108
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
109
109
  stub_post("/1/account/update_profile.json").
110
- with(:body => {:url => "https://github.com/sferik"}).
110
+ with(:body => {:url => "https://github.com/sferik", :include_entities => "false"}).
111
111
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
112
112
  end
113
113
  it "should request the correct resource" do
114
114
  @t.set("url", "https://github.com/sferik")
115
115
  a_post("/1/account/update_profile.json").
116
- with(:body => {:url => "https://github.com/sferik"}).
116
+ with(:body => {:url => "https://github.com/sferik", :include_entities => "false"}).
117
117
  should have_been_made
118
118
  end
119
119
  it "should have the correct output" do
@@ -0,0 +1,223 @@
1
+ # encoding: utf-8
2
+ require 'helper'
3
+
4
+ describe T::CLI::Unfollow::All do
5
+
6
+ before do
7
+ @t = T::CLI.new
8
+ @old_stderr = $stderr
9
+ $stderr = StringIO.new
10
+ @old_stdout = $stdout
11
+ $stdout = StringIO.new
12
+ end
13
+
14
+ after do
15
+ $stderr = @old_stderr
16
+ $stdout = @old_stdout
17
+ end
18
+
19
+ describe "#listed" do
20
+ before do
21
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
22
+ stub_get("/1/account/verify_credentials.json").
23
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
24
+ end
25
+ context "no users" do
26
+ before do
27
+ stub_get("/1/lists/members.json").
28
+ with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
29
+ to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
30
+ end
31
+ it "should request the correct resource" do
32
+ @t.unfollow("all", "listed", "presidents")
33
+ a_get("/1/account/verify_credentials.json").
34
+ should have_been_made
35
+ a_get("/1/lists/members.json").
36
+ with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
37
+ should have_been_made
38
+ end
39
+ it "should have the correct output" do
40
+ @t.unfollow("all", "listed", "presidents")
41
+ $stdout.string.chomp.should == "@testcli is already not following any list members."
42
+ end
43
+ end
44
+ context "one user" do
45
+ before do
46
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
47
+ stub_get("/1/lists/members.json").
48
+ with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
49
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
50
+ stub_delete("/1/friendships/destroy.json").
51
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
52
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
53
+ end
54
+ it "should request the correct resource" do
55
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
56
+ $stdin.should_receive(:gets).and_return("yes")
57
+ @t.unfollow("all", "listed", "presidents")
58
+ a_get("/1/account/verify_credentials.json").
59
+ should have_been_made
60
+ a_get("/1/lists/members.json").
61
+ with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
62
+ should have_been_made
63
+ a_delete("/1/friendships/destroy.json").
64
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
65
+ should have_been_made
66
+ end
67
+ context "yes" do
68
+ it "should have the correct output" do
69
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
70
+ $stdin.should_receive(:gets).and_return("yes")
71
+ @t.unfollow("all", "listed", "presidents")
72
+ $stdout.string.should =~ /^@testcli is no longer following @sferik\.$/
73
+ $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
74
+ end
75
+ end
76
+ context "no" do
77
+ it "should have the correct output" do
78
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
79
+ $stdin.should_receive(:gets).and_return("no")
80
+ @t.unfollow("all", "listed", "presidents")
81
+ $stdout.string.chomp.should == ""
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ describe "#nonfollowers" do
88
+ before do
89
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
90
+ end
91
+ context "no users" do
92
+ before do
93
+ stub_get("/1/friends/ids.json").
94
+ with(:query => {:cursor => "-1"}).
95
+ to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
96
+ stub_get("/1/followers/ids.json").
97
+ with(:query => {:cursor => "-1"}).
98
+ to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
99
+ end
100
+ it "should request the correct resource" do
101
+ @t.unfollow("all", "nonfollowers")
102
+ a_get("/1/friends/ids.json").
103
+ with(:query => {:cursor => "-1"}).
104
+ should have_been_made
105
+ a_get("/1/followers/ids.json").
106
+ with(:query => {:cursor => "-1"}).
107
+ should have_been_made
108
+ end
109
+ it "should have the correct output" do
110
+ @t.unfollow("all", "nonfollowers")
111
+ $stdout.string.chomp.should == "@testcli is already not following any non-followers."
112
+ end
113
+ end
114
+ context "one user" do
115
+ before do
116
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
117
+ stub_get("/1/friends/ids.json").
118
+ with(:query => {:cursor => "-1"}).
119
+ to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
120
+ stub_get("/1/followers/ids.json").
121
+ with(:query => {:cursor => "-1"}).
122
+ to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
123
+ stub_delete("/1/friendships/destroy.json").
124
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
125
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
126
+ end
127
+ it "should request the correct resource" do
128
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
129
+ $stdin.should_receive(:gets).and_return("yes")
130
+ @t.unfollow("all", "nonfollowers")
131
+ a_get("/1/friends/ids.json").
132
+ with(:query => {:cursor => "-1"}).
133
+ should have_been_made
134
+ a_get("/1/followers/ids.json").
135
+ with(:query => {:cursor => "-1"}).
136
+ should have_been_made
137
+ a_delete("/1/friendships/destroy.json").
138
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
139
+ should have_been_made
140
+ end
141
+ context "yes" do
142
+ it "should have the correct output" do
143
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
144
+ $stdin.should_receive(:gets).and_return("yes")
145
+ @t.unfollow("all", "nonfollowers")
146
+ $stdout.string.should =~ /^@testcli is no longer following @sferik\.$/
147
+ $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
148
+ end
149
+ end
150
+ context "no" do
151
+ it "should have the correct output" do
152
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
153
+ $stdin.should_receive(:gets).and_return("no")
154
+ @t.unfollow("all", "nonfollowers")
155
+ $stdout.string.chomp.should == ""
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ describe "#users" do
162
+ before do
163
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
164
+ end
165
+ context "no users" do
166
+ before do
167
+ stub_get("/1/friends/ids.json").
168
+ with(:query => {:cursor => "-1"}).
169
+ to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
170
+ end
171
+ it "should request the correct resource" do
172
+ @t.unfollow("all", "users")
173
+ a_get("/1/friends/ids.json").
174
+ with(:query => {:cursor => "-1"}).
175
+ should have_been_made
176
+ end
177
+ it "should have the correct output" do
178
+ @t.unfollow("all", "users")
179
+ $stdout.string.chomp.should == "@testcli is already not following anyone."
180
+ end
181
+ end
182
+ context "four users" do
183
+ before do
184
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
185
+ stub_get("/1/friends/ids.json").
186
+ with(:query => {:cursor => "-1"}).
187
+ to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
188
+ stub_delete("/1/friendships/destroy.json").
189
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
190
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
191
+ end
192
+ it "should request the correct resource" do
193
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
194
+ $stdin.should_receive(:gets).and_return("yes")
195
+ @t.unfollow("all", "users")
196
+ a_get("/1/friends/ids.json").
197
+ with(:query => {:cursor => "-1"}).
198
+ should have_been_made
199
+ a_delete("/1/friendships/destroy.json").
200
+ with(:query => {:user_id => "7505382", :include_entities => "false"}).
201
+ should have_been_made
202
+ end
203
+ context "yes" do
204
+ it "should have the correct output" do
205
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
206
+ $stdin.should_receive(:gets).and_return("yes")
207
+ @t.unfollow("all", "users")
208
+ $stdout.string.should =~ /^@testcli is no longer following @sferik\.$/
209
+ $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
210
+ end
211
+ end
212
+ context "no" do
213
+ it "should have the correct output" do
214
+ $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
215
+ $stdin.should_receive(:gets).and_return("no")
216
+ @t.unfollow("all", "users")
217
+ $stdout.string.chomp.should == ""
218
+ end
219
+ end
220
+ end
221
+ end
222
+
223
+ end
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ require 'helper'
3
+
4
+ describe T::CLI::Unfollow do
5
+
6
+ before do
7
+ @t = T::CLI.new
8
+ @old_stderr = $stderr
9
+ $stderr = StringIO.new
10
+ @old_stdout = $stdout
11
+ $stdout = StringIO.new
12
+ end
13
+
14
+ after do
15
+ $stderr = @old_stderr
16
+ $stdout = @old_stdout
17
+ end
18
+
19
+ describe "#users" do
20
+ before do
21
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
22
+ end
23
+ context "no users" do
24
+ it "should exit" do
25
+ lambda do
26
+ @t.follow("users")
27
+ end.should raise_error
28
+ end
29
+ end
30
+ context "one user" do
31
+ before do
32
+ stub_delete("/1/friendships/destroy.json").
33
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
34
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
35
+ end
36
+ it "should request the correct resource" do
37
+ @t.unfollow("users", "sferik")
38
+ a_delete("/1/friendships/destroy.json").
39
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
40
+ should have_been_made
41
+ end
42
+ it "should have the correct output" do
43
+ @t.unfollow("users", "sferik")
44
+ $stdout.string.should =~ /^@testcli is no longer following @sferik\.$/
45
+ end
46
+ end
47
+ context "two users" do
48
+ before do
49
+ stub_delete("/1/friendships/destroy.json").
50
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
51
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
52
+ stub_delete("/1/friendships/destroy.json").
53
+ with(:query => {:screen_name => "gem", :include_entities => "false"}).
54
+ to_return(:body => fixture("gem.json"), :headers => {:content_type => "application/json; charset=utf-8"})
55
+ end
56
+ it "should request the correct resource" do
57
+ @t.unfollow("users", "sferik", "gem")
58
+ a_delete("/1/friendships/destroy.json").
59
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
60
+ should have_been_made
61
+ a_delete("/1/friendships/destroy.json").
62
+ with(:query => {:screen_name => "gem", :include_entities => "false"}).
63
+ should have_been_made
64
+ end
65
+ it "should have the correct output" do
66
+ @t.unfollow("users", "sferik", "gem")
67
+ $stdout.string.should =~ /^@testcli is no longer following @sferik\.$/
68
+ $stdout.string.should =~ /^@testcli is no longer following @gem\.$/
69
+ $stdout.string.should =~ /^@testcli is no longer following 2 users\.$/
70
+ end
71
+ end
72
+ end
73
+
74
+ end
@@ -19,7 +19,7 @@ describe T::CLI do
19
19
 
20
20
  describe "#account" do
21
21
  before do
22
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
22
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
23
23
  end
24
24
  it "should have the correct output" do
25
25
  @t.accounts
@@ -66,15 +66,15 @@ describe T::CLI do
66
66
 
67
67
  describe "#block" do
68
68
  before do
69
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
69
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
70
70
  stub_post("/1/blocks/create.json").
71
- with(:body => {:screen_name => "sferik"}).
71
+ with(:body => {:screen_name => "sferik", :include_entities => "false"}).
72
72
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
73
73
  end
74
74
  it "should request the correct resource" do
75
75
  @t.block("sferik")
76
76
  a_post("/1/blocks/create.json").
77
- with(:body => {:screen_name => "sferik"}).
77
+ with(:body => {:screen_name => "sferik", :include_entities => "false"}).
78
78
  should have_been_made
79
79
  end
80
80
  it "should have the correct output" do
@@ -86,11 +86,13 @@ describe T::CLI do
86
86
  describe "#direct_messages" do
87
87
  before do
88
88
  stub_get("/1/direct_messages.json").
89
+ with(:query => {:include_entities => "false"}).
89
90
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
90
91
  end
91
92
  it "should request the correct resource" do
92
93
  @t.direct_messages
93
94
  a_get("/1/direct_messages.json").
95
+ with(:query => {:include_entities => "false"}).
94
96
  should have_been_made
95
97
  end
96
98
  it "should have the correct output" do
@@ -122,15 +124,15 @@ describe T::CLI do
122
124
 
123
125
  describe "#dm" do
124
126
  before do
125
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
127
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
126
128
  stub_post("/1/direct_messages/new.json").
127
- with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
129
+ with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
128
130
  to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
129
131
  end
130
132
  it "should request the correct resource" do
131
133
  @t.dm("pengwynn", "Creating a fixture for the Twitter gem")
132
134
  a_post("/1/direct_messages/new.json").
133
- with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
135
+ with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem", :include_entities => "false"}).
134
136
  should have_been_made
135
137
  end
136
138
  it "should have the correct output" do
@@ -141,12 +143,12 @@ describe T::CLI do
141
143
 
142
144
  describe "#favorite" do
143
145
  before do
144
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
146
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
145
147
  end
146
148
  context "not found" do
147
149
  before do
148
150
  stub_get("/1/users/show.json").
149
- with(:query => {:screen_name => "sferik"}).
151
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
150
152
  to_return(:body => '{}', :headers => {:content_type => "application/json; charset=utf-8"})
151
153
  end
152
154
  it "should exit" do
@@ -158,7 +160,7 @@ describe T::CLI do
158
160
  context "forbidden" do
159
161
  before do
160
162
  stub_get("/1/users/show.json").
161
- with(:query => {:screen_name => "sferik"}).
163
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
162
164
  to_return(:body => '{"error":"Forbidden"}', :headers => {:content_type => "application/json; charset=utf-8"}, :status => 403)
163
165
  end
164
166
  it "should exit" do
@@ -170,20 +172,20 @@ describe T::CLI do
170
172
  context "duplicate" do
171
173
  before do
172
174
  stub_get("/1/users/show.json").
173
- with(:query => {:screen_name => "sferik"}).
175
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
174
176
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
175
177
  stub_post("/1/favorites/create/26755176471724032.json").
176
178
  to_return(:body => '{"error":"You have already favorited this status."}', :headers => {:content_type => "application/json; charset=utf-8"}, :status => 403)
177
179
  end
178
180
  it "should have the correct output" do
179
181
  @t.favorite("sferik")
180
- $stdout.string.should =~ /^@testcli favorited @sferik's latest status: RT @tenderlove: \[ANN\] sqlite3-ruby => sqlite3$/
182
+ $stdout.string.should =~ /^@testcli favorited @sferik's latest status: "RT @tenderlove: \[ANN\] sqlite3-ruby => sqlite3"$/
181
183
  end
182
184
  end
183
185
  context "found" do
184
186
  before do
185
187
  stub_get("/1/users/show.json").
186
- with(:query => {:screen_name => "sferik"}).
188
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
187
189
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
188
190
  stub_post("/1/favorites/create/26755176471724032.json").
189
191
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
@@ -191,34 +193,53 @@ describe T::CLI do
191
193
  it "should request the correct resource" do
192
194
  @t.favorite("sferik")
193
195
  a_get("/1/users/show.json").
194
- with(:query => {:screen_name => "sferik"}).
196
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
195
197
  should have_been_made
196
198
  a_post("/1/favorites/create/26755176471724032.json").
197
199
  should have_been_made
198
200
  end
199
201
  it "should have the correct output" do
200
202
  @t.favorite("sferik")
201
- $stdout.string.should =~ /^@testcli favorited @sferik's latest status: RT @tenderlove: \[ANN\] sqlite3-ruby => sqlite3$/
203
+ $stdout.string.should =~ /^@testcli favorited @sferik's latest status: "RT @tenderlove: \[ANN\] sqlite3-ruby => sqlite3"$/
202
204
  end
203
205
  end
204
206
  end
205
207
 
206
- describe "#follow" do
208
+ describe "#favorites" do
207
209
  before do
208
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
209
- stub_post("/1/friendships/create.json").
210
- with(:body => {:screen_name => "sferik"}).
211
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
210
+ stub_get("/1/favorites.json").
211
+ with(:query => {:include_entities => "false"}).
212
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
212
213
  end
213
214
  it "should request the correct resource" do
214
- @t.follow("sferik")
215
- a_post("/1/friendships/create.json").
216
- with(:body => {:screen_name => "sferik"}).
215
+ @t.favorites
216
+ a_get("/1/favorites.json").
217
+ with(:query => {:include_entities => "false"}).
217
218
  should have_been_made
218
219
  end
219
220
  it "should have the correct output" do
220
- @t.follow("sferik")
221
- $stdout.string.should =~ /^@testcli is now following @sferik\.$/
221
+ @t.favorites
222
+ $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
223
+ sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
224
+ sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
225
+ sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
226
+ sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
227
+ sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
228
+ sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
229
+ sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
230
+ sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
231
+ sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
232
+ sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
233
+ sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
234
+ sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
235
+ sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
236
+ sferik: Ping: kills MySpace dead. (about 1 year ago)
237
+ sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
238
+ sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
239
+ sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
240
+ sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
241
+ sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
242
+ eos
222
243
  end
223
244
  end
224
245
 
@@ -226,7 +247,7 @@ describe T::CLI do
226
247
  context "not found" do
227
248
  before do
228
249
  stub_get("/1/users/show.json").
229
- with(:query => {:screen_name => "sferik"}).
250
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
230
251
  to_return(:body => '{}', :headers => {:content_type => "application/json; charset=utf-8"})
231
252
  end
232
253
  it "should exit" do
@@ -238,13 +259,13 @@ describe T::CLI do
238
259
  context "found" do
239
260
  before do
240
261
  stub_get("/1/users/show.json").
241
- with(:query => {:screen_name => "sferik"}).
262
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
242
263
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
243
264
  end
244
265
  it "should request the correct resource" do
245
266
  @t.get("sferik")
246
267
  a_get("/1/users/show.json").
247
- with(:query => {:screen_name => "sferik"}).
268
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
248
269
  should have_been_made
249
270
  end
250
271
  it "should have the correct output" do
@@ -257,11 +278,13 @@ describe T::CLI do
257
278
  describe "#mentions" do
258
279
  before do
259
280
  stub_get("/1/statuses/mentions.json").
281
+ with(:query => {:include_entities => "false"}).
260
282
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
261
283
  end
262
284
  it "should request the correct resource" do
263
285
  @t.mentions
264
286
  a_get("/1/statuses/mentions.json").
287
+ with(:query => {:include_entities => "false"}).
265
288
  should have_been_made
266
289
  end
267
290
  it "should have the correct output" do
@@ -303,12 +326,12 @@ describe T::CLI do
303
326
 
304
327
  describe "#reply" do
305
328
  before do
306
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__), :location => true)
329
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc", :location => true)
307
330
  stub_get("/1/users/show.json").
308
- with(:query => {:screen_name => "sferik"}).
331
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
309
332
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
310
333
  stub_post("/1/statuses/update.json").
311
- with(:body => {:in_reply_to_status_id => "26755176471724032", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748"}).
334
+ with(:body => {:in_reply_to_status_id => "26755176471724032", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
312
335
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
313
336
  stub_request(:get, "http://checkip.dyndns.org/").
314
337
  to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
@@ -318,10 +341,10 @@ describe T::CLI do
318
341
  it "should request the correct resource" do
319
342
  @t.reply("sferik", "Testing")
320
343
  a_get("/1/users/show.json").
321
- with(:query => {:screen_name => "sferik"}).
344
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
322
345
  should have_been_made
323
346
  a_post("/1/statuses/update.json").
324
- with(:body => {:in_reply_to_status_id => "26755176471724032", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748"}).
347
+ with(:body => {:in_reply_to_status_id => "26755176471724032", :status => "@sferik Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
325
348
  should have_been_made
326
349
  a_request(:get, "http://checkip.dyndns.org/").
327
350
  should have_been_made
@@ -336,12 +359,12 @@ describe T::CLI do
336
359
 
337
360
  describe "#retweet" do
338
361
  before do
339
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
362
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
340
363
  end
341
364
  context "not found" do
342
365
  before do
343
366
  stub_get("/1/users/show.json").
344
- with(:query => {:screen_name => "sferik"}).
367
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
345
368
  to_return(:body => '{}', :headers => {:content_type => "application/json; charset=utf-8"})
346
369
  end
347
370
  it "should exit" do
@@ -353,7 +376,7 @@ describe T::CLI do
353
376
  context "forbidden" do
354
377
  before do
355
378
  stub_get("/1/users/show.json").
356
- with(:query => {:screen_name => "sferik"}).
379
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
357
380
  to_return(:body => '{"error":"Forbidden"}', :headers => {:content_type => "application/json; charset=utf-8"}, :status => 403)
358
381
  end
359
382
  it "should exit" do
@@ -365,20 +388,20 @@ describe T::CLI do
365
388
  context "duplicate" do
366
389
  before do
367
390
  stub_get("/1/users/show.json").
368
- with(:query => {:screen_name => "sferik"}).
391
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
369
392
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
370
393
  stub_post("/1/statuses/retweet/26755176471724032.json").
371
394
  to_return(:body => '{"error":"sharing is not permissable for this status (Share validations failed)"}', :headers => {:content_type => "application/json; charset=utf-8"}, :status => 403)
372
395
  end
373
396
  it "should have the correct output" do
374
397
  @t.retweet("sferik")
375
- $stdout.string.should =~ /^@testcli retweeted @sferik's latest status: RT @tenderlove: \[ANN\] sqlite3-ruby =&gt; sqlite3$/
398
+ $stdout.string.should =~ /^@testcli retweeted @sferik's latest status: "RT @tenderlove: \[ANN\] sqlite3-ruby =&gt; sqlite3"$/
376
399
  end
377
400
  end
378
401
  context "found" do
379
402
  before do
380
403
  stub_get("/1/users/show.json").
381
- with(:query => {:screen_name => "sferik"}).
404
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
382
405
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
383
406
  stub_post("/1/statuses/retweet/26755176471724032.json").
384
407
  to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
@@ -386,26 +409,62 @@ describe T::CLI do
386
409
  it "should request the correct resource" do
387
410
  @t.retweet("sferik")
388
411
  a_get("/1/users/show.json").
389
- with(:query => {:screen_name => "sferik"}).
412
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
390
413
  should have_been_made
391
414
  a_post("/1/statuses/retweet/26755176471724032.json").
392
415
  should have_been_made
393
416
  end
394
417
  it "should have the correct output" do
395
418
  @t.retweet("sferik")
396
- $stdout.string.should =~ /^@testcli retweeted @sferik's latest status: RT @tenderlove: \[ANN\] sqlite3-ruby =&gt; sqlite3$/
419
+ $stdout.string.should =~ /^@testcli retweeted @sferik's latest status: "RT @tenderlove: \[ANN\] sqlite3-ruby =&gt; sqlite3"$/
397
420
  end
398
421
  end
399
422
  end
400
423
 
424
+ describe "#search" do
425
+ before do
426
+ stub_request(:get, "https://search.twitter.com/search.json").
427
+ with(:query => {:q => "twitter", :include_entities => "false"}).
428
+ to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
429
+ end
430
+ it "should request the correct resource" do
431
+ @t.search("twitter")
432
+ a_request(:get, "https://search.twitter.com/search.json").
433
+ with(:query => {:q => "twitter", :include_entities => "false"}).
434
+ should have_been_made
435
+ end
436
+ it "should have the correct output" do
437
+ @t.search("twitter")
438
+ $stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
439
+ killermelons: @KaiserKuo from not too far away your new twitter icon looks like Vader. (about 1 year ago)
440
+ FelipeNoMore: RT @nicoMaiden: RT @golden254: Quien habra sido el habil en decirle al negro piñera que era cantante?/el mismo que le dijo a @copano que la lleva en twitter (about 1 year ago)
441
+ Je_eF: é cada louco que tem nesse twitter que o vicio nao me deixa largar isso jamé (about 1 year ago)
442
+ TriceyTrice2U: @Jae_Savage same name as twitter (about 1 year ago)
443
+ eternity4: @enishi39 Its awesome huh? Its ALL Spn anime epicness!! I had a tough time getting twitter to put it up.xD (about 1 year ago)
444
+ twittag: [Twitter*feed] 船井総研発!一番店の法則~実費型治療院(整骨院・接骨院)・サロン経営コンサルティングブログ~ http://bit.ly/cxoSGL (about 1 year ago)
445
+ twittag: [Twitter*feed] ニフティクラウド、明日より「サーバーコピー」、「カスタマイズイメージ」、「オートスケール」、「基本監視・パフォーマンスチャート」を公開 | P2P today ダブルスラッシュ http://wslash.com/?p=2959 (about 1 year ago)
446
+ twittag: [Twitter*feed] ニフティクラウド、明日より「サーバーコピー」、「カスタマイズイメージ」、「オートスケール」、「基本監視・パフォーマンスチャート」を公開 | P2P today ダブルスラッシュ http://bit.ly/aziQQo (about 1 year ago)
447
+ ArcangelHak: Bueno pues me desconectó de twitter al tatto le falta todavía un rato y ya casi tengo sueño (about 1 year ago)
448
+ recycledhumor: Just in case you are wondering, Weird Al (@alyankovic) has 1,862,789 followers on Twitter. Correction: 1,862,790 followers on Twitter. (about 1 year ago)
449
+ junitaaa: Lama&quot; chat di twitter nih..hahaha RT @buntutbabi: Lo yg mulai juga,siiietRT @Junitaaa: Kelakuan @buntutbabi (cont) http://tl.gd/6m1dcv (about 1 year ago)
450
+ twittag: [Twitter*feed] 『かちびと.net』 の人気エントリー - はてなブックマーク http://bit.ly/9Yx6xS (about 1 year ago)
451
+ avexnews: @ICONIQ_NEWS opened!She gain attention by collaboration song「I'm lovin' you」wif EXILE・ATSUSHI.Get her newest info here! http://bit.ly/dymm8v (about 1 year ago)
452
+ WildIvory92: RT @FiercePrinceJ: People on Twitter Gossip about other People, Hate others? This Is Twitter Nothing More, Nothing Less. (about 1 year ago)
453
+ twittag: [Twitter*feed] Now Playing Friends - リニューアル式 : R49 http://bit.ly/bmlA5g (about 1 year ago)
454
+ eos
455
+ end
456
+ end
457
+
401
458
  describe "#sent_messages" do
402
459
  before do
403
460
  stub_get("/1/direct_messages/sent.json").
461
+ with(:query => {:include_entities => "false"}).
404
462
  to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
405
463
  end
406
464
  it "should request the correct resource" do
407
465
  @t.sent_messages
408
466
  a_get("/1/direct_messages/sent.json").
467
+ with(:query => {:include_entities => "false"}).
409
468
  should have_been_made
410
469
  end
411
470
  it "should have the correct output" do
@@ -438,27 +497,30 @@ describe T::CLI do
438
497
  describe "#stats" do
439
498
  before do
440
499
  stub_get("/1/users/show.json").
441
- with(:query => {:screen_name => "sferik"}).
500
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
442
501
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
443
502
  end
444
503
  it "should request the correct resource" do
445
504
  @t.stats("sferik")
446
505
  a_get("/1/users/show.json").
447
- with(:query => {:screen_name => "sferik"}).
506
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
448
507
  should have_been_made
449
508
  end
450
509
  it "should have the correct output" do
451
510
  @t.stats("sferik")
452
- $stdout.string.should =~ /^Followers: 1,048$/
511
+ $stdout.string.should =~ /^Tweets: 3,479$/
453
512
  $stdout.string.should =~ /^Following: 197$/
513
+ $stdout.string.should =~ /^Followers: 1,048$/
514
+ $stdout.string.should =~ /^Favorites: 1,040$/
515
+ $stdout.string.should =~ /^Listed: 41$/
454
516
  end
455
517
  end
456
518
 
457
519
  describe "#status" do
458
520
  before do
459
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__), :location => true)
521
+ @t.options = @t.options.merge(:profile => fixture_path + "/.trc", :location => true)
460
522
  stub_post("/1/statuses/update.json").
461
- with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748"}).
523
+ with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
462
524
  to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
463
525
  stub_request(:get, "http://checkip.dyndns.org/").
464
526
  to_return(:body => fixture("checkip.html"), :headers => {:content_type => "text/html"})
@@ -468,7 +530,7 @@ describe T::CLI do
468
530
  it "should request the correct resource" do
469
531
  @t.status("Testing")
470
532
  a_post("/1/statuses/update.json").
471
- with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748"}).
533
+ with(:body => {:status => "Testing", :lat => "37.76969909668", :long => "-122.39330291748", :include_entities => "false", :trim_user => "true"}).
472
534
  should have_been_made
473
535
  a_request(:get, "http://checkip.dyndns.org/").
474
536
  should have_been_made
@@ -484,13 +546,13 @@ describe T::CLI do
484
546
  describe "#suggest" do
485
547
  before do
486
548
  stub_get("/1/users/recommendations.json").
487
- with(:query => {:limit => "1"}).
549
+ with(:query => {:limit => "1", :include_entities => "false"}).
488
550
  to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
489
551
  end
490
552
  it "should request the correct resource" do
491
553
  @t.suggest
492
554
  a_get("/1/users/recommendations.json").
493
- with(:query => {:limit => "1"}).
555
+ with(:query => {:limit => "1", :include_entities => "false"}).
494
556
  should have_been_made
495
557
  end
496
558
  it "should have the correct output" do
@@ -502,11 +564,13 @@ describe T::CLI do
502
564
  describe "#timeline" do
503
565
  before do
504
566
  stub_get("/1/statuses/home_timeline.json").
567
+ with(:query => {:include_entities => "false"}).
505
568
  to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
506
569
  end
507
570
  it "should request the correct resource" do
508
571
  @t.timeline
509
572
  a_get("/1/statuses/home_timeline.json").
573
+ with(:query => {:include_entities => "false"}).
510
574
  should have_been_made
511
575
  end
512
576
  it "should have the correct output" do
@@ -535,25 +599,6 @@ describe T::CLI do
535
599
  end
536
600
  end
537
601
 
538
- describe "#unfollow" do
539
- before do
540
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
541
- stub_delete("/1/friendships/destroy.json").
542
- with(:query => {:screen_name => "sferik"}).
543
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
544
- end
545
- it "should request the correct resource" do
546
- @t.unfollow("sferik")
547
- a_delete("/1/friendships/destroy.json").
548
- with(:query => {:screen_name => "sferik"}).
549
- should have_been_made
550
- end
551
- it "should have the correct output" do
552
- @t.unfollow("sferik")
553
- $stdout.string.should =~ /^@testcli is no longer following @sferik\.$/
554
- end
555
- end
556
-
557
602
  describe "#version" do
558
603
  it "should have the correct output" do
559
604
  @t.version
@@ -564,13 +609,13 @@ describe T::CLI do
564
609
  describe "#whois" do
565
610
  before do
566
611
  stub_get("/1/users/show.json").
567
- with(:query => {:screen_name => "sferik"}).
612
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
568
613
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
569
614
  end
570
615
  it "should request the correct resource" do
571
616
  @t.whois("sferik")
572
617
  a_get("/1/users/show.json").
573
- with(:query => {:screen_name => "sferik"}).
618
+ with(:query => {:screen_name => "sferik", :include_entities => "false"}).
574
619
  should have_been_made
575
620
  end
576
621
  it "should have the correct output" do