t 2.5.0 → 2.6.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.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +9 -3
- data/bin/t +1 -1
- data/lib/t/cli.rb +39 -8
- data/lib/t/collectable.rb +6 -4
- data/lib/t/core_ext/kernel.rb +1 -1
- data/lib/t/delete.rb +12 -0
- data/lib/t/list.rb +1 -1
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +268 -239
- data/spec/delete_spec.rb +54 -42
- data/spec/fixtures/ids_list.json +1 -0
- data/spec/fixtures/ids_list2.json +1 -0
- data/spec/list_spec.rb +30 -30
- data/spec/search_spec.rb +59 -61
- data/spec/set_spec.rb +7 -7
- data/spec/stream_spec.rb +2 -2
- data/t.gemspec +4 -4
- metadata +10 -6
data/spec/delete_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe T::Delete do
|
|
21
21
|
describe '#block' do
|
22
22
|
before do
|
23
23
|
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
24
|
-
stub_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
24
|
+
stub_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
25
25
|
end
|
26
26
|
it 'requests the correct resource' do
|
27
27
|
@delete.block('sferik')
|
@@ -34,7 +34,7 @@ describe T::Delete do
|
|
34
34
|
context '--id' do
|
35
35
|
before do
|
36
36
|
@delete.options = @delete.options.merge('id' => true)
|
37
|
-
stub_post('/1.1/blocks/destroy.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
37
|
+
stub_post('/1.1/blocks/destroy.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
38
38
|
end
|
39
39
|
it 'requests the correct resource' do
|
40
40
|
@delete.block('7505382')
|
@@ -46,28 +46,25 @@ describe T::Delete do
|
|
46
46
|
describe '#dm' do
|
47
47
|
before do
|
48
48
|
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
49
|
-
stub_get('/1.1/direct_messages/show.json').with(:query => {:id => '1773478249'}).to_return(:body => fixture('direct_message.json'))
|
50
|
-
stub_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1773478249'}).to_return(:body => fixture('direct_message.json'))
|
49
|
+
stub_get('/1.1/direct_messages/show.json').with(:query => {:id => '1773478249'}).to_return(:body => fixture('direct_message.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
50
|
+
stub_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1773478249'}).to_return(:body => fixture('direct_message.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
51
51
|
end
|
52
52
|
it 'requests the correct resource' do
|
53
|
-
expect(
|
54
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
53
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the direct message to @pengwynn: \"Creating a fixture for the Twitter gem\"? [y/N] ", false).and_return('yes')
|
55
54
|
@delete.dm('1773478249')
|
56
55
|
expect(a_get('/1.1/direct_messages/show.json').with(:query => {:id => '1773478249'})).to have_been_made
|
57
56
|
expect(a_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1773478249'})).to have_been_made
|
58
57
|
end
|
59
58
|
context 'yes' do
|
60
59
|
it 'has the correct output' do
|
61
|
-
expect(
|
62
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
60
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the direct message to @pengwynn: \"Creating a fixture for the Twitter gem\"? [y/N] ", false).and_return('yes')
|
63
61
|
@delete.dm('1773478249')
|
64
62
|
expect($stdout.string.chomp).to eq "@testcli deleted the direct message sent to @pengwynn: \"Creating a fixture for the Twitter gem\""
|
65
63
|
end
|
66
64
|
end
|
67
65
|
context 'no' do
|
68
66
|
it 'has the correct output' do
|
69
|
-
expect(
|
70
|
-
expect($stdin).to receive(:gets).and_return('no')
|
67
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the direct message to @pengwynn: \"Creating a fixture for the Twitter gem\"? [y/N] ", false).and_return('no')
|
71
68
|
@delete.dm('1773478249')
|
72
69
|
expect($stdout.string.chomp).to be_empty
|
73
70
|
end
|
@@ -90,28 +87,25 @@ describe T::Delete do
|
|
90
87
|
describe '#favorite' do
|
91
88
|
before do
|
92
89
|
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
93
|
-
stub_get('/1.1/statuses/show/28439861609.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'))
|
94
|
-
stub_post('/1.1/favorites/destroy.json').with(:body => {:id => '28439861609'}).to_return(:body => fixture('status.json'))
|
90
|
+
stub_get('/1.1/statuses/show/28439861609.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
91
|
+
stub_post('/1.1/favorites/destroy.json').with(:body => {:id => '28439861609'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
95
92
|
end
|
96
93
|
it 'requests the correct resource' do
|
97
|
-
expect(
|
98
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
94
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ", false).and_return('yes')
|
99
95
|
@delete.favorite('28439861609')
|
100
96
|
expect(a_get('/1.1/statuses/show/28439861609.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
101
97
|
expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '28439861609'})).to have_been_made
|
102
98
|
end
|
103
99
|
context 'yes' do
|
104
100
|
it 'has the correct output' do
|
105
|
-
expect(
|
106
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
101
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ", false).and_return('yes')
|
107
102
|
@delete.favorite('28439861609')
|
108
103
|
expect($stdout.string).to match(/^@testcli unfavorited @sferik's status: "The problem with your code is that it's doing exactly what you told it to do\."$/)
|
109
104
|
end
|
110
105
|
end
|
111
106
|
context 'no' do
|
112
107
|
it 'has the correct output' do
|
113
|
-
expect(
|
114
|
-
expect($stdin).to receive(:gets).and_return('no')
|
108
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ", false).and_return('no')
|
115
109
|
@delete.favorite('28439861609')
|
116
110
|
expect($stdout.string.chomp).to be_empty
|
117
111
|
end
|
@@ -134,29 +128,26 @@ describe T::Delete do
|
|
134
128
|
describe '#list' do
|
135
129
|
before do
|
136
130
|
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
137
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
138
|
-
stub_get('/1.1/lists/show.json').with(:query => {:
|
139
|
-
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'}).to_return(:body => fixture('list.json'))
|
131
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
132
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
133
|
+
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
140
134
|
end
|
141
135
|
it 'requests the correct resource' do
|
142
|
-
expect(
|
143
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
136
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ", false).and_return('yes')
|
144
137
|
@delete.list('presidents')
|
145
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
138
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
146
139
|
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
147
140
|
end
|
148
141
|
context 'yes' do
|
149
142
|
it 'has the correct output' do
|
150
|
-
expect(
|
151
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
143
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ", false).and_return('yes')
|
152
144
|
@delete.list('presidents')
|
153
145
|
expect($stdout.string.chomp).to eq "@testcli deleted the list \"presidents\"."
|
154
146
|
end
|
155
147
|
end
|
156
148
|
context 'no' do
|
157
149
|
it 'has the correct output' do
|
158
|
-
expect(
|
159
|
-
expect($stdin).to receive(:gets).and_return('no')
|
150
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ", false).and_return('no')
|
160
151
|
@delete.list('presidents')
|
161
152
|
expect($stdout.string.chomp).to be_empty
|
162
153
|
end
|
@@ -167,7 +158,7 @@ describe T::Delete do
|
|
167
158
|
end
|
168
159
|
it 'requests the correct resource' do
|
169
160
|
@delete.list('presidents')
|
170
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
161
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
171
162
|
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
172
163
|
end
|
173
164
|
it 'has the correct output' do
|
@@ -178,44 +169,65 @@ describe T::Delete do
|
|
178
169
|
context '--id' do
|
179
170
|
before do
|
180
171
|
@delete.options = @delete.options.merge('id' => true)
|
181
|
-
stub_get('/1.1/lists/show.json').with(:query => {:
|
172
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :list_id => '8863586'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
182
173
|
end
|
183
174
|
it 'requests the correct resource' do
|
184
|
-
expect(
|
185
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
175
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ", false).and_return('yes')
|
186
176
|
@delete.list('8863586')
|
187
|
-
expect(a_get('/1.1/lists/show.json').with(:query => {:
|
188
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
177
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
178
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
189
179
|
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
190
180
|
end
|
191
181
|
end
|
192
182
|
end
|
193
183
|
|
184
|
+
describe '#mute' do
|
185
|
+
before do
|
186
|
+
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
187
|
+
stub_post('/1.1/mutes/users/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
188
|
+
end
|
189
|
+
it 'requests the correct resource' do
|
190
|
+
@delete.mute('sferik')
|
191
|
+
expect(a_post('/1.1/mutes/users/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
192
|
+
end
|
193
|
+
it 'has the correct output' do
|
194
|
+
@delete.mute('sferik')
|
195
|
+
expect($stdout.string).to match(/^@testcli unmuted 1 user\.$/)
|
196
|
+
end
|
197
|
+
context '--id' do
|
198
|
+
before do
|
199
|
+
@delete.options = @delete.options.merge('id' => true)
|
200
|
+
stub_post('/1.1/mutes/users/destroy.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
201
|
+
end
|
202
|
+
it 'requests the correct resource' do
|
203
|
+
@delete.mute('7505382')
|
204
|
+
expect(a_post('/1.1/mutes/users/destroy.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
194
209
|
describe '#status' do
|
195
210
|
before do
|
196
211
|
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
197
|
-
stub_get('/1.1/statuses/show/26755176471724032.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'))
|
198
|
-
stub_post('/1.1/statuses/destroy/26755176471724032.json').with(:body => {:trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
212
|
+
stub_get('/1.1/statuses/show/26755176471724032.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
213
|
+
stub_post('/1.1/statuses/destroy/26755176471724032.json').with(:body => {:trim_user => 'true'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
199
214
|
end
|
200
215
|
it 'requests the correct resource' do
|
201
|
-
expect(
|
202
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
216
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ", false).and_return('yes')
|
203
217
|
@delete.status('26755176471724032')
|
204
218
|
expect(a_get('/1.1/statuses/show/26755176471724032.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
205
219
|
expect(a_post('/1.1/statuses/destroy/26755176471724032.json').with(:body => {:trim_user => 'true'})).to have_been_made
|
206
220
|
end
|
207
221
|
context 'yes' do
|
208
222
|
it 'has the correct output' do
|
209
|
-
expect(
|
210
|
-
expect($stdin).to receive(:gets).and_return('yes')
|
223
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ", false).and_return('yes')
|
211
224
|
@delete.status('26755176471724032')
|
212
225
|
expect($stdout.string.chomp).to eq "@testcli deleted the Tweet: \"The problem with your code is that it's doing exactly what you told it to do.\""
|
213
226
|
end
|
214
227
|
end
|
215
228
|
context 'no' do
|
216
229
|
it 'has the correct output' do
|
217
|
-
expect(
|
218
|
-
expect($stdin).to receive(:gets).and_return('no')
|
230
|
+
expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ", false).and_return('no')
|
219
231
|
@delete.status('26755176471724032')
|
220
232
|
expect($stdout.string.chomp).to be_empty
|
221
233
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"previous_cursor":0,"next_cursor_str":"1305102810874389703","ids":[20009713],"previous_cursor_str":"0","next_cursor":1305102810874389703}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"previous_cursor":-1305101990888327757,"next_cursor_str":"0","ids":[14100886],"previous_cursor_str":"-1305101990888327757","next_cursor":0}
|
data/spec/list_spec.rb
CHANGED
@@ -31,13 +31,13 @@ describe T::List do
|
|
31
31
|
describe '#add' do
|
32
32
|
before do
|
33
33
|
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
34
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
35
|
-
stub_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
34
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
35
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
36
36
|
end
|
37
37
|
it 'requests the correct resource' do
|
38
38
|
@list.add('presidents', 'BarackObama')
|
39
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
40
|
-
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
39
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
40
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'})).to have_been_made
|
41
41
|
end
|
42
42
|
it 'has the correct output' do
|
43
43
|
@list.add('presidents', 'BarackObama')
|
@@ -46,21 +46,21 @@ describe T::List do
|
|
46
46
|
context '--id' do
|
47
47
|
before do
|
48
48
|
@list.options = @list.options.merge('id' => true)
|
49
|
-
stub_post('/1.1/lists/members/create_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :
|
49
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_id => '7505382'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
50
50
|
end
|
51
51
|
it 'requests the correct resource' do
|
52
52
|
@list.add('presidents', '7505382')
|
53
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
54
|
-
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :
|
53
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
54
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_id => '7505382'})).to have_been_made
|
55
55
|
end
|
56
56
|
end
|
57
57
|
context 'Twitter is down' do
|
58
58
|
it 'retries 3 times and then raise an error' do
|
59
|
-
stub_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
59
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
60
60
|
expect do
|
61
61
|
@list.add('presidents', 'BarackObama')
|
62
62
|
end.to raise_error(Twitter::Error::BadGateway)
|
63
|
-
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
63
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'})).to have_been_made.times(3)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -68,7 +68,7 @@ describe T::List do
|
|
68
68
|
describe '#create' do
|
69
69
|
before do
|
70
70
|
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
71
|
-
stub_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'}).to_return(:body => fixture('list.json'))
|
71
|
+
stub_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
72
72
|
end
|
73
73
|
it 'requests the correct resource' do
|
74
74
|
@list.create('presidents')
|
@@ -83,7 +83,7 @@ describe T::List do
|
|
83
83
|
describe '#information' do
|
84
84
|
before do
|
85
85
|
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
86
|
-
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
86
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
87
87
|
end
|
88
88
|
it 'requests the correct resource' do
|
89
89
|
@list.information('presidents')
|
@@ -128,7 +128,7 @@ URL https://twitter.com/sferik/presidents
|
|
128
128
|
context '--id' do
|
129
129
|
before do
|
130
130
|
@list.options = @list.options.merge('id' => true)
|
131
|
-
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
131
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
132
132
|
end
|
133
133
|
it 'requests the correct resource' do
|
134
134
|
@list.information('7505382/presidents')
|
@@ -152,7 +152,7 @@ ID,Description,Slug,Screen name,Created at,Members,Subscribers,Following,Mode,UR
|
|
152
152
|
|
153
153
|
describe '#members' do
|
154
154
|
before do
|
155
|
-
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'))
|
155
|
+
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
156
156
|
end
|
157
157
|
it 'requests the correct resource' do
|
158
158
|
@list.members('presidents')
|
@@ -277,7 +277,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
277
277
|
context '--id' do
|
278
278
|
before do
|
279
279
|
@list.options = @list.options.merge('id' => true)
|
280
|
-
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'))
|
280
|
+
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
281
281
|
end
|
282
282
|
it 'requests the correct resource' do
|
283
283
|
@list.members('7505382/presidents')
|
@@ -290,37 +290,37 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
290
290
|
describe '#remove' do
|
291
291
|
before do
|
292
292
|
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
293
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
293
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
294
294
|
end
|
295
295
|
it 'requests the correct resource' do
|
296
|
-
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
296
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
297
297
|
@list.remove('presidents', 'BarackObama')
|
298
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
299
|
-
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
298
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
299
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'})).to have_been_made
|
300
300
|
end
|
301
301
|
it 'has the correct output' do
|
302
|
-
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
302
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
303
303
|
@list.remove('presidents', 'BarackObama')
|
304
304
|
expect($stdout.string.split("\n").first).to eq "@testcli removed 1 member from the list \"presidents\"."
|
305
305
|
end
|
306
306
|
context '--id' do
|
307
307
|
before do
|
308
308
|
@list.options = @list.options.merge('id' => true)
|
309
|
-
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :
|
309
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_id => '7505382'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
310
310
|
end
|
311
311
|
it 'requests the correct resource' do
|
312
312
|
@list.remove('presidents', '7505382')
|
313
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
314
|
-
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :
|
313
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
314
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_id => '7505382'})).to have_been_made
|
315
315
|
end
|
316
316
|
end
|
317
317
|
context 'Twitter is down' do
|
318
318
|
it 'retries 3 times and then raise an error' do
|
319
|
-
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
319
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
320
320
|
expect do
|
321
321
|
@list.remove('presidents', 'BarackObama')
|
322
322
|
end.to raise_error(Twitter::Error::BadGateway)
|
323
|
-
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :
|
323
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_id => '7505382'})).to have_been_made.times(3)
|
324
324
|
end
|
325
325
|
end
|
326
326
|
end
|
@@ -328,7 +328,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
328
328
|
describe '#timeline' do
|
329
329
|
before do
|
330
330
|
@list.options = @list.options.merge('color' => 'always')
|
331
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
331
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
332
332
|
end
|
333
333
|
it 'requests the correct resource' do
|
334
334
|
@list.timeline('presidents')
|
@@ -700,7 +700,7 @@ ID,Posted at,Screen name,Text
|
|
700
700
|
context '--decode-uris' do
|
701
701
|
before do
|
702
702
|
@list.options = @list.options.merge('decode_uris' => true)
|
703
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'))
|
703
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
704
704
|
end
|
705
705
|
it 'requests the correct resource' do
|
706
706
|
@list.timeline('presidents')
|
@@ -775,9 +775,9 @@ ID Posted at Screen name Text
|
|
775
775
|
end
|
776
776
|
context '--number' do
|
777
777
|
before do
|
778
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
779
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '200', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'))
|
780
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :max_id => '265500541700956160', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
778
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
779
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '200', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
780
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :max_id => '265500541700956160', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
781
781
|
end
|
782
782
|
it 'limits the number of results to 1' do
|
783
783
|
@list.options = @list.options.merge('number' => 1)
|
@@ -799,7 +799,7 @@ ID Posted at Screen name Text
|
|
799
799
|
context '--id' do
|
800
800
|
before do
|
801
801
|
@list.options = @list.options.merge('id' => true)
|
802
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_id => '7505382', :count => '20', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
802
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_id => '7505382', :count => '20', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
803
803
|
end
|
804
804
|
it 'requests the correct resource' do
|
805
805
|
@list.timeline('7505382/presidents')
|
data/spec/search_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe T::Search do
|
|
31
31
|
|
32
32
|
describe '#all' do
|
33
33
|
before do
|
34
|
-
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'))
|
34
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
35
35
|
end
|
36
36
|
it 'requests the correct resource' do
|
37
37
|
@search.all('twitter')
|
@@ -180,9 +180,9 @@ ID Posted at Screen name Text
|
|
180
180
|
end
|
181
181
|
context '--number' do
|
182
182
|
before do
|
183
|
-
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '1', :include_entities => 'false'}).to_return(:body => fixture('search2.json'))
|
184
|
-
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'))
|
185
|
-
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => '1', :max_id => '415600158693675007'}).to_return(:body => fixture('search2.json'))
|
183
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '1', :include_entities => 'false'}).to_return(:body => fixture('search2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
184
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
185
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => '1', :max_id => '415600158693675007'}).to_return(:body => fixture('search2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
186
186
|
end
|
187
187
|
it 'limits the number of results to 1' do
|
188
188
|
@search.options = @search.options.merge('number' => 1)
|
@@ -200,8 +200,8 @@ ID Posted at Screen name Text
|
|
200
200
|
|
201
201
|
describe '#favorites' do
|
202
202
|
before do
|
203
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
204
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
203
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
204
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
205
205
|
end
|
206
206
|
it 'requests the correct resource' do
|
207
207
|
@search.favorites('twitter')
|
@@ -236,8 +236,8 @@ ID,Posted at,Screen name,Text
|
|
236
236
|
context '--decode-uris' do
|
237
237
|
before(:each) do
|
238
238
|
@search.options = @search.options.merge('decode_uris' => true)
|
239
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'))
|
240
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'}).to_return(:body => fixture('empty_array.json'))
|
239
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
240
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
241
241
|
end
|
242
242
|
it 'requests the correct resource' do
|
243
243
|
@search.favorites('twitter')
|
@@ -264,7 +264,7 @@ ID Posted at Screen name Text
|
|
264
264
|
end
|
265
265
|
context 'Twitter is down' do
|
266
266
|
it 'retries 3 times and then raise an error' do
|
267
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502)
|
267
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
268
268
|
expect do
|
269
269
|
@search.favorites('twitter')
|
270
270
|
end.to raise_error(Twitter::Error::BadGateway)
|
@@ -273,8 +273,8 @@ ID Posted at Screen name Text
|
|
273
273
|
end
|
274
274
|
context 'with a user passed' do
|
275
275
|
before do
|
276
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
277
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
276
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
277
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
278
278
|
end
|
279
279
|
it 'requests the correct resource' do
|
280
280
|
@search.favorites('sferik', 'twitter')
|
@@ -296,8 +296,8 @@ ID Posted at Screen name Text
|
|
296
296
|
context '--id' do
|
297
297
|
before do
|
298
298
|
@search.options = @search.options.merge('id' => true)
|
299
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
300
|
-
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
299
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
300
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
301
301
|
end
|
302
302
|
it 'requests the correct resource' do
|
303
303
|
@search.favorites('7505382', 'twitter')
|
@@ -322,8 +322,8 @@ ID Posted at Screen name Text
|
|
322
322
|
|
323
323
|
describe '#mentions' do
|
324
324
|
before do
|
325
|
-
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
326
|
-
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
325
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
326
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
327
327
|
end
|
328
328
|
it 'requests the correct resource' do
|
329
329
|
@search.mentions('twitter')
|
@@ -358,8 +358,8 @@ ID,Posted at,Screen name,Text
|
|
358
358
|
context '--decode-uris' do
|
359
359
|
before(:each) do
|
360
360
|
@search.options = @search.options.merge('decode_uris' => true)
|
361
|
-
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'))
|
362
|
-
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'}).to_return(:body => fixture('empty_array.json'))
|
361
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
362
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
363
363
|
end
|
364
364
|
it 'requests the correct resource' do
|
365
365
|
@search.mentions('twitter')
|
@@ -386,7 +386,7 @@ ID Posted at Screen name Text
|
|
386
386
|
end
|
387
387
|
context 'Twitter is down' do
|
388
388
|
it 'retries 3 times and then raise an error' do
|
389
|
-
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502)
|
389
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
390
390
|
expect do
|
391
391
|
@search.mentions('twitter')
|
392
392
|
end.to raise_error(Twitter::Error::BadGateway)
|
@@ -397,8 +397,8 @@ ID Posted at Screen name Text
|
|
397
397
|
|
398
398
|
describe '#list' do
|
399
399
|
before do
|
400
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
401
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
400
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
401
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
402
402
|
end
|
403
403
|
it 'requests the correct resource' do
|
404
404
|
@search.list('presidents', 'twitter')
|
@@ -433,8 +433,8 @@ ID,Posted at,Screen name,Text
|
|
433
433
|
context '--decode-uris' do
|
434
434
|
before(:each) do
|
435
435
|
@search.options = @search.options.merge('decode_uris' => true)
|
436
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'))
|
437
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'))
|
436
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
437
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
438
438
|
end
|
439
439
|
it 'requests the correct resource' do
|
440
440
|
@search.list('presidents', 'twitter')
|
@@ -467,8 +467,8 @@ ID Posted at Screen name Text
|
|
467
467
|
context '--id' do
|
468
468
|
before do
|
469
469
|
@search.options = @search.options.merge('id' => true)
|
470
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
471
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
470
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
471
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
472
472
|
end
|
473
473
|
it 'requests the correct resource' do
|
474
474
|
@search.list('7505382/presidents', 'twitter')
|
@@ -479,7 +479,7 @@ ID Posted at Screen name Text
|
|
479
479
|
end
|
480
480
|
context 'Twitter is down' do
|
481
481
|
it 'retries 3 times and then raise an error' do
|
482
|
-
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:status => 502)
|
482
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
483
483
|
expect do
|
484
484
|
@search.list('presidents', 'twitter')
|
485
485
|
end.to raise_error(Twitter::Error::BadGateway)
|
@@ -490,8 +490,8 @@ ID Posted at Screen name Text
|
|
490
490
|
|
491
491
|
describe '#retweets' do
|
492
492
|
before do
|
493
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
494
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
493
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
494
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
495
495
|
end
|
496
496
|
it 'requests the correct resource' do
|
497
497
|
@search.retweets('mosaic')
|
@@ -521,8 +521,8 @@ ID,Posted at,Screen name,Text
|
|
521
521
|
context '--decode-uris' do
|
522
522
|
before(:each) do
|
523
523
|
@search.options = @search.options.merge('decode_uris' => true)
|
524
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'))
|
525
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'))
|
524
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
525
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
526
526
|
end
|
527
527
|
it 'requests the correct resource' do
|
528
528
|
@search.retweets('mosaic')
|
@@ -548,7 +548,7 @@ ID Posted at Screen name Text
|
|
548
548
|
end
|
549
549
|
context 'Twitter is down' do
|
550
550
|
it 'retries 3 times and then raise an error' do
|
551
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:status => 502)
|
551
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
552
552
|
expect do
|
553
553
|
@search.retweets('mosaic')
|
554
554
|
end.to raise_error(Twitter::Error::BadGateway)
|
@@ -557,8 +557,8 @@ ID Posted at Screen name Text
|
|
557
557
|
end
|
558
558
|
context 'with a user passed' do
|
559
559
|
before do
|
560
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
561
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
560
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
561
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
562
562
|
end
|
563
563
|
it 'requests the correct resource' do
|
564
564
|
@search.retweets('sferik', 'mosaic')
|
@@ -576,8 +576,8 @@ ID Posted at Screen name Text
|
|
576
576
|
context '--id' do
|
577
577
|
before do
|
578
578
|
@search.options = @search.options.merge('id' => true)
|
579
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
580
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
579
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
580
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
581
581
|
end
|
582
582
|
it 'requests the correct resource' do
|
583
583
|
@search.retweets('7505382', 'mosaic')
|
@@ -598,8 +598,8 @@ ID Posted at Screen name Text
|
|
598
598
|
|
599
599
|
describe '#timeline' do
|
600
600
|
before do
|
601
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
602
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
601
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
602
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
603
603
|
end
|
604
604
|
it 'requests the correct resource' do
|
605
605
|
@search.timeline('twitter')
|
@@ -634,8 +634,8 @@ ID,Posted at,Screen name,Text
|
|
634
634
|
context '--decode-uris' do
|
635
635
|
before(:each) do
|
636
636
|
@search.options = @search.options.merge('decode_uris' => true)
|
637
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'))
|
638
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'))
|
637
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
638
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
639
639
|
end
|
640
640
|
it 'requests the correct resource' do
|
641
641
|
@search.timeline('twitter')
|
@@ -650,8 +650,8 @@ ID,Posted at,Screen name,Text
|
|
650
650
|
context '--exclude=replies' do
|
651
651
|
before do
|
652
652
|
@search.options = @search.options.merge('exclude' => 'replies')
|
653
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
654
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
653
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
654
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
655
655
|
end
|
656
656
|
it 'excludes replies' do
|
657
657
|
@search.timeline
|
@@ -662,8 +662,8 @@ ID,Posted at,Screen name,Text
|
|
662
662
|
context '--exclude=retweets' do
|
663
663
|
before do
|
664
664
|
@search.options = @search.options.merge('exclude' => 'retweets')
|
665
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
666
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
665
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
666
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
667
667
|
end
|
668
668
|
it 'excludes retweets' do
|
669
669
|
@search.timeline
|
@@ -687,7 +687,7 @@ ID Posted at Screen name Text
|
|
687
687
|
context '--max-id' do
|
688
688
|
before do
|
689
689
|
@search.options = @search.options.merge('max_id' => 244_104_558_433_951_744)
|
690
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
690
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
691
691
|
end
|
692
692
|
it 'requests the correct resource' do
|
693
693
|
@search.timeline('twitter')
|
@@ -697,8 +697,8 @@ ID Posted at Screen name Text
|
|
697
697
|
context '--since-id' do
|
698
698
|
before do
|
699
699
|
@search.options = @search.options.merge('since_id' => 244_104_558_433_951_744)
|
700
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
701
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
700
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
701
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
702
702
|
end
|
703
703
|
it 'requests the correct resource' do
|
704
704
|
@search.timeline('twitter')
|
@@ -708,7 +708,7 @@ ID Posted at Screen name Text
|
|
708
708
|
end
|
709
709
|
context 'Twitter is down' do
|
710
710
|
it 'retries 3 times and then raise an error' do
|
711
|
-
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502)
|
711
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
712
712
|
expect do
|
713
713
|
@search.timeline('twitter')
|
714
714
|
end.to raise_error(Twitter::Error::BadGateway)
|
@@ -717,8 +717,8 @@ ID Posted at Screen name Text
|
|
717
717
|
end
|
718
718
|
context 'with a user passed' do
|
719
719
|
before do
|
720
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
721
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
720
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
721
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
722
722
|
end
|
723
723
|
it 'requests the correct resource' do
|
724
724
|
@search.timeline('sferik', 'twitter')
|
@@ -753,8 +753,8 @@ ID,Posted at,Screen name,Text
|
|
753
753
|
context '--id' do
|
754
754
|
before do
|
755
755
|
@search.options = @search.options.merge('id' => true)
|
756
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
757
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
756
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
757
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
758
758
|
end
|
759
759
|
it 'requests the correct resource' do
|
760
760
|
@search.timeline('7505382', 'twitter')
|
@@ -778,7 +778,7 @@ ID Posted at Screen name Text
|
|
778
778
|
context '--max-id' do
|
779
779
|
before do
|
780
780
|
@search.options = @search.options.merge('max_id' => 244_104_558_433_951_744)
|
781
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
781
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
782
782
|
end
|
783
783
|
it 'requests the correct resource' do
|
784
784
|
@search.timeline('sferik', 'twitter')
|
@@ -788,8 +788,8 @@ ID Posted at Screen name Text
|
|
788
788
|
context '--since-id' do
|
789
789
|
before do
|
790
790
|
@search.options = @search.options.merge('since_id' => 244_104_558_433_951_744)
|
791
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'))
|
792
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'))
|
791
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
792
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
793
793
|
end
|
794
794
|
it 'requests the correct resource' do
|
795
795
|
@search.timeline('sferik', 'twitter')
|
@@ -799,7 +799,7 @@ ID Posted at Screen name Text
|
|
799
799
|
end
|
800
800
|
context 'Twitter is down' do
|
801
801
|
it 'retries 3 times and then raise an error' do
|
802
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik', :count => '200', :include_entities => 'false'}).to_return(:status => 502)
|
802
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik', :count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
803
803
|
expect do
|
804
804
|
@search.timeline('sferik', 'twitter')
|
805
805
|
end.to raise_error(Twitter::Error::BadGateway)
|
@@ -811,15 +811,13 @@ ID Posted at Screen name Text
|
|
811
811
|
|
812
812
|
describe '#users' do
|
813
813
|
before do
|
814
|
-
stub_get('/1.1/users/search.json').with(:query => {:page => '1', :q => 'Erik'}).to_return(:body => fixture('users.json'))
|
815
|
-
stub_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'}).to_return(:body => fixture('empty_array.json'))
|
814
|
+
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'})
|
815
|
+
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'})
|
816
816
|
end
|
817
817
|
it 'requests the correct resource' do
|
818
818
|
@search.users('Erik')
|
819
|
-
1.
|
820
|
-
|
821
|
-
expect(a_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'})).to have_been_made
|
822
|
-
end
|
819
|
+
expect(a_get('/1.1/users/search.json').with(:query => {:page => '1', :q => 'Erik'})).to have_been_made
|
820
|
+
expect(a_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'})).to have_been_made
|
823
821
|
end
|
824
822
|
it 'has the correct output' do
|
825
823
|
@search.users('Erik')
|
@@ -934,7 +932,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
934
932
|
end
|
935
933
|
context 'Twitter is down' do
|
936
934
|
it 'retries 3 times and then raise an error' do
|
937
|
-
stub_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'}).to_return(:status => 502)
|
935
|
+
stub_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
|
938
936
|
expect do
|
939
937
|
@search.users('Erik')
|
940
938
|
end.to raise_error(Twitter::Error::BadGateway)
|