tweetstream 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.

Potentially problematic release.


This version of tweetstream might be problematic. Click here for more details.

@@ -2,7 +2,7 @@ require 'helper'
2
2
 
3
3
  describe TweetStream::Client do
4
4
  before do
5
- @stream = stub("EM::Twitter::Client",
5
+ @stream = double("EM::Twitter::Client",
6
6
  :connect => true,
7
7
  :unbind => true,
8
8
  :each => true,
@@ -14,8 +14,8 @@ describe TweetStream::Client do
14
14
  :on_unauthorized => true,
15
15
  :on_enhance_your_calm => true
16
16
  )
17
- EM.stub!(:run).and_yield
18
- EM::Twitter::Client.stub!(:connect).and_return(@stream)
17
+ allow(EM).to receive(:run).and_yield
18
+ allow(EM::Twitter::Client).to receive(:connect).and_return(@stream)
19
19
  end
20
20
 
21
21
  describe "basic auth" do
@@ -30,7 +30,7 @@ describe TweetStream::Client do
30
30
  end
31
31
 
32
32
  it "tries to connect via a JSON stream with basic auth" do
33
- EM::Twitter::Client.should_receive(:connect).with(
33
+ expect(EM::Twitter::Client).to receive(:connect).with(
34
34
  :path => '/1.1/statuses/filter.json',
35
35
  :method => 'POST',
36
36
  :user_agent => TweetStream::Configuration::DEFAULT_USER_AGENT,
@@ -61,7 +61,7 @@ describe TweetStream::Client do
61
61
  end
62
62
 
63
63
  it "tries to connect via a JSON stream with oauth" do
64
- EM::Twitter::Client.should_receive(:connect).with(
64
+ expect(EM::Twitter::Client).to receive(:connect).with(
65
65
  :path => '/1.1/statuses/filter.json',
66
66
  :method => 'POST',
67
67
  :user_agent => TweetStream::Configuration::DEFAULT_USER_AGENT,
@@ -10,7 +10,7 @@ describe TweetStream::Client do
10
10
  end
11
11
  @client = TweetStream::Client.new
12
12
 
13
- @stream = stub("EM::Twitter::Client",
13
+ @stream = double("EM::Twitter::Client",
14
14
  :connect => true,
15
15
  :unbind => true,
16
16
  :each => true,
@@ -22,39 +22,39 @@ describe TweetStream::Client do
22
22
  :on_unauthorized => true,
23
23
  :on_enhance_your_calm => true
24
24
  )
25
- EM.stub!(:run).and_yield
26
- EM::Twitter::Client.stub!(:connect).and_return(@stream)
25
+ allow(EM).to receive(:run).and_yield
26
+ allow(EM::Twitter::Client).to receive(:connect).and_return(@stream)
27
27
  end
28
28
 
29
29
  describe "Site Stream support" do
30
30
  context "when calling #sitestream" do
31
31
  it "sends the sitestream host" do
32
- EM::Twitter::Client.should_receive(:connect).with(hash_including(:host => "sitestream.twitter.com")).and_return(@stream)
32
+ expect(EM::Twitter::Client).to receive(:connect).with(hash_including(:host => "sitestream.twitter.com")).and_return(@stream)
33
33
  @client.sitestream
34
34
  end
35
35
 
36
36
  it "uses the sitestream uri" do
37
- @client.should_receive(:start).once.with('/1.1/site.json', an_instance_of(Hash)).and_return(@stream)
37
+ expect(@client).to receive(:start).once.with('/1.1/site.json', an_instance_of(Hash)).and_return(@stream)
38
38
  @client.sitestream
39
39
  end
40
40
 
41
41
  it "supports :followings => true" do
42
- @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:with => 'followings')).and_return(@stream)
42
+ expect(@client).to receive(:start).once.with('/1.1/site.json', hash_including(:with => 'followings')).and_return(@stream)
43
43
  @client.sitestream(['115192457'], :followings => true)
44
44
  end
45
45
 
46
46
  it "supports :with => 'followings'" do
47
- @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:with => 'followings')).and_return(@stream)
47
+ expect(@client).to receive(:start).once.with('/1.1/site.json', hash_including(:with => 'followings')).and_return(@stream)
48
48
  @client.sitestream(['115192457'], :with => 'followings')
49
49
  end
50
50
 
51
51
  it "supports :with => 'user'" do
52
- @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:with => 'user')).and_return(@stream)
52
+ expect(@client).to receive(:start).once.with('/1.1/site.json', hash_including(:with => 'user')).and_return(@stream)
53
53
  @client.sitestream(['115192457'], :with => 'user')
54
54
  end
55
55
 
56
56
  it "supports :replies => 'all'" do
57
- @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:replies => 'all')).and_return(@stream)
57
+ expect(@client).to receive(:start).once.with('/1.1/site.json', hash_including(:replies => 'all')).and_return(@stream)
58
58
  @client.sitestream(['115192457'], :replies => 'all')
59
59
  end
60
60
 
@@ -67,14 +67,30 @@ describe TweetStream::Client do
67
67
  }
68
68
  end
69
69
  it "assigns the control_uri" do
70
- @stream.should_receive(:each).and_yield(@control_response.to_json)
70
+ expect(@stream).to receive(:each).and_yield(@control_response.to_json)
71
71
  @client.sitestream
72
72
 
73
73
  expect(@client.control_uri).to eq("/1.1/site/c/01_225167_334389048B872A533002B34D73F8C29FD09EFC50")
74
74
  end
75
75
 
76
+ it 'invokes the on_control callback' do
77
+ called = false
78
+ expect(@stream).to receive(:each).and_yield(@control_response.to_json)
79
+ @client.on_control { called = true }
80
+ @client.sitestream
81
+
82
+ expect(called).to be_true
83
+ end
84
+
85
+ it 'is controllable when a control_uri has been received' do
86
+ expect(@stream).to receive(:each).and_yield(@control_response.to_json)
87
+ @client.sitestream
88
+
89
+ expect(@client.controllable?).to be_true
90
+ end
91
+
76
92
  it "instantiates a SiteStreamClient" do
77
- @stream.should_receive(:each).and_yield(@control_response.to_json)
93
+ expect(@stream).to receive(:each).and_yield(@control_response.to_json)
78
94
  @client.sitestream
79
95
 
80
96
  expect(@client.control).to be_kind_of(TweetStream::SiteStreamClient)
@@ -83,7 +99,7 @@ describe TweetStream::Client do
83
99
  it "passes the client's on_error to the SiteStreamClient" do
84
100
  called = false
85
101
  @client.on_error { |err| called = true }
86
- @stream.should_receive(:each).and_yield(@control_response.to_json)
102
+ expect(@stream).to receive(:each).and_yield(@control_response.to_json)
87
103
  @client.sitestream
88
104
 
89
105
  @client.control.on_error.call
@@ -99,7 +115,7 @@ describe TweetStream::Client do
99
115
  end
100
116
 
101
117
  it "yields a site stream message" do
102
- @stream.should_receive(:each).and_yield(@ss_message.to_json)
118
+ expect(@stream).to receive(:each).and_yield(@ss_message.to_json)
103
119
  yielded_status = nil
104
120
  @client.sitestream do |message|
105
121
  yielded_status = message
@@ -110,7 +126,7 @@ describe TweetStream::Client do
110
126
  expect(yielded_status[:message][:text]).to eq('Oo oo aa aa')
111
127
  end
112
128
  it "yields itself if block has an arity of 2" do
113
- @stream.should_receive(:each).and_yield(@ss_message.to_json)
129
+ expect(@stream).to receive(:each).and_yield(@ss_message.to_json)
114
130
  yielded_client = nil
115
131
  @client.sitestream do |_, client|
116
132
  yielded_client = client
@@ -126,7 +142,7 @@ describe TweetStream::Client do
126
142
  end
127
143
 
128
144
  it "yields a friends list array" do
129
- @stream.should_receive(:each).and_yield(@friends_list.to_json)
145
+ expect(@stream).to receive(:each).and_yield(@friends_list.to_json)
130
146
  yielded_list = nil
131
147
  @client.on_friends do |friends|
132
148
  yielded_list = friends
@@ -13,7 +13,7 @@ describe TweetStream::Client do
13
13
 
14
14
  describe "#start" do
15
15
  before do
16
- @stream = stub("EM::Twitter::Client",
16
+ @stream = double("EM::Twitter::Client",
17
17
  :connect => true,
18
18
  :unbind => true,
19
19
  :each => true,
@@ -25,33 +25,33 @@ describe TweetStream::Client do
25
25
  :on_unauthorized => true,
26
26
  :on_enhance_your_calm => true
27
27
  )
28
- EM.stub!(:run).and_yield
29
- EM::Twitter::Client.stub!(:connect).and_return(@stream)
28
+ allow(EM).to receive(:run).and_yield
29
+ allow(EM::Twitter::Client).to receive(:connect).and_return(@stream)
30
30
  end
31
31
 
32
32
  it "connects if the reactor is already running" do
33
- EM.stub!(:reactor_running?).and_return(true)
34
- @client.should_receive(:connect)
33
+ allow(EM).to receive(:reactor_running?).and_return(true)
34
+ expect(@client).to receive(:connect)
35
35
  @client.track('abc')
36
36
  end
37
37
 
38
38
  it "starts the reactor if not already running" do
39
- EM.should_receive(:run).once
39
+ expect(EM).to receive(:run).once
40
40
  @client.track('abc')
41
41
  end
42
42
 
43
43
  it "warns when callbacks are passed as options" do
44
- @stream.stub(:each).and_yield(nil)
45
- Kernel.should_receive(:warn).with(/Passing callbacks via the options hash is deprecated and will be removed in TweetStream 3.0/)
44
+ allow(@stream).to receive(:each).and_return
45
+ expect(Kernel).to receive(:warn).with(/Passing callbacks via the options hash is deprecated and will be removed in TweetStream 3.0/)
46
46
  @client.track('abc', :inited => Proc.new { })
47
47
  end
48
48
 
49
49
  describe 'proxy usage' do
50
50
  it 'connects with a proxy' do
51
51
  @client = TweetStream::Client.new(:proxy => { :uri => 'http://someproxy:8081'})
52
- EM::Twitter::Client.should_receive(:connect).
52
+ expect(EM::Twitter::Client).to receive(:connect).
53
53
  with(hash_including(:proxy => { :uri => 'http://someproxy:8081'})).and_return(@stream)
54
- @stream.should_receive(:each).and_return
54
+ expect(@stream).to receive(:each).and_return
55
55
  @client.track('abc')
56
56
  end
57
57
  end
@@ -59,18 +59,18 @@ describe TweetStream::Client do
59
59
  describe "#each" do
60
60
  it "calls the appropriate parser" do
61
61
  @client = TweetStream::Client.new
62
- Yajl::Parser.should_receive(:parse).twice.and_return({})
63
- @stream.should_receive(:each).and_yield(sample_tweets[0].to_json)
62
+ expect(MultiJson).to receive(:decode).and_return({})
63
+ expect(@stream).to receive(:each).and_yield(sample_tweets[0].to_json)
64
64
  @client.track('abc','def')
65
65
  end
66
66
 
67
67
  it "yields a Twitter::Tweet" do
68
- @stream.should_receive(:each).and_yield(sample_tweets[0].to_json)
68
+ expect(@stream).to receive(:each).and_yield(sample_tweets[0].to_json)
69
69
  @client.track('abc'){|s| expect(s).to be_kind_of(Twitter::Tweet)}
70
70
  end
71
71
 
72
72
  it "yields the client if a block with arity 2 is given" do
73
- @stream.should_receive(:each).and_yield(sample_tweets[0].to_json)
73
+ expect(@stream).to receive(:each).and_yield(sample_tweets[0].to_json)
74
74
  @client.track('abc'){|s,c| expect(c).to eq(@client)}
75
75
  end
76
76
 
@@ -79,7 +79,7 @@ describe TweetStream::Client do
79
79
  tweet[:id] = 123
80
80
  tweet[:user][:screen_name] = 'monkey'
81
81
  tweet[:text] = "Oo oo aa aa"
82
- @stream.should_receive(:each).and_yield(tweet.to_json)
82
+ expect(@stream).to receive(:each).and_yield(tweet.to_json)
83
83
  @client.track('abc') do |s|
84
84
  expect(s[:id]).to eq(123)
85
85
  expect(s.user.screen_name).to eq('monkey')
@@ -88,14 +88,14 @@ describe TweetStream::Client do
88
88
  end
89
89
 
90
90
  it "calls the on_stall_warning callback if specified" do
91
- @stream.should_receive(:each).and_yield(fixture('stall_warning.json'))
91
+ expect(@stream).to receive(:each).and_yield(fixture('stall_warning.json'))
92
92
  @client.on_stall_warning do |warning|
93
93
  expect(warning[:code]).to eq('FALLING_BEHIND')
94
94
  end.track('abc')
95
95
  end
96
96
 
97
97
  it "calls the on_scrub_geo callback if specified" do
98
- @stream.should_receive(:each).and_yield(fixture('scrub_geo.json'))
98
+ expect(@stream).to receive(:each).and_yield(fixture('scrub_geo.json'))
99
99
  @client.on_scrub_geo do |up_to_status_id, user_id|
100
100
  expect(up_to_status_id).to eq(9876)
101
101
  expect(user_id).to eq(1234)
@@ -103,7 +103,7 @@ describe TweetStream::Client do
103
103
  end
104
104
 
105
105
  it "calls the on_delete callback" do
106
- @stream.should_receive(:each).and_yield(fixture('delete.json'))
106
+ expect(@stream).to receive(:each).and_yield(fixture('delete.json'))
107
107
  @client.on_delete do |id, user_id|
108
108
  expect(id).to eq(1234)
109
109
  expect(user_id).to eq(3)
@@ -112,7 +112,7 @@ describe TweetStream::Client do
112
112
 
113
113
  it "calls the on_limit callback" do
114
114
  limit = nil
115
- @stream.should_receive(:each).and_yield(fixture('limit.json'))
115
+ expect(@stream).to receive(:each).and_yield(fixture('limit.json'))
116
116
  @client.on_limit do |l|
117
117
  limit = l
118
118
  end.track('abc')
@@ -122,7 +122,7 @@ describe TweetStream::Client do
122
122
 
123
123
  it "calls the on_status_withheld callback" do
124
124
  status = nil
125
- @stream.should_receive(:each).and_yield(fixture('status_withheld.json'))
125
+ expect(@stream).to receive(:each).and_yield(fixture('status_withheld.json'))
126
126
  @client.on_status_withheld do |s|
127
127
  status = s
128
128
  end.track('abc')
@@ -132,7 +132,7 @@ describe TweetStream::Client do
132
132
 
133
133
  it "calls the on_user_withheld callback" do
134
134
  status = nil
135
- @stream.should_receive(:each).and_yield(fixture('user_withheld.json'))
135
+ expect(@stream).to receive(:each).and_yield(fixture('user_withheld.json'))
136
136
  @client.on_user_withheld do |s|
137
137
  status = s
138
138
  end.track('abc')
@@ -143,7 +143,7 @@ describe TweetStream::Client do
143
143
  context "using on_anything" do
144
144
  it "yields the raw hash" do
145
145
  hash = {:id => 1234}
146
- @stream.should_receive(:each).and_yield(hash.to_json)
146
+ expect(@stream).to receive(:each).and_yield(hash.to_json)
147
147
  yielded_hash = nil
148
148
  @client.on_anything do |h|
149
149
  yielded_hash = h
@@ -154,7 +154,7 @@ describe TweetStream::Client do
154
154
  end
155
155
  it "yields itself if block has an arity of 2" do
156
156
  hash = {:id => 1234}
157
- @stream.should_receive(:each).and_yield(hash.to_json)
157
+ expect(@stream).to receive(:each).and_yield(hash.to_json)
158
158
  yielded_client = nil
159
159
  @client.on_anything do |_, client|
160
160
  yielded_client = client
@@ -170,7 +170,7 @@ describe TweetStream::Client do
170
170
  tweet[:id] = 123
171
171
  tweet[:user][:screen_name] = 'monkey'
172
172
  tweet[:text] = "Oo oo aa aa"
173
- @stream.should_receive(:each).and_yield(tweet.to_json)
173
+ expect(@stream).to receive(:each).and_yield(tweet.to_json)
174
174
  yielded_status = nil
175
175
  @client.on_timeline_status do |status|
176
176
  yielded_status = status
@@ -181,7 +181,7 @@ describe TweetStream::Client do
181
181
  expect(yielded_status.text).to eq('Oo oo aa aa')
182
182
  end
183
183
  it "yields itself if block has an arity of 2" do
184
- @stream.should_receive(:each).and_yield(sample_tweets[0].to_json)
184
+ expect(@stream).to receive(:each).and_yield(sample_tweets[0].to_json)
185
185
  yielded_client = nil
186
186
  @client.on_timeline_status do |_, client|
187
187
  yielded_client = client
@@ -196,7 +196,7 @@ describe TweetStream::Client do
196
196
  direct_message = sample_direct_messages[0]
197
197
  direct_message[:direct_message][:id] = 1234
198
198
  direct_message[:direct_message][:sender][:screen_name] = "coder"
199
- @stream.should_receive(:each).and_yield(direct_message.to_json)
199
+ expect(@stream).to receive(:each).and_yield(direct_message.to_json)
200
200
  yielded_dm = nil
201
201
  @client.on_direct_message do |dm|
202
202
  yielded_dm = dm
@@ -207,7 +207,7 @@ describe TweetStream::Client do
207
207
  end
208
208
 
209
209
  it "yields itself if block has an arity of 2" do
210
- @stream.should_receive(:each).and_yield(sample_direct_messages[0].to_json)
210
+ expect(@stream).to receive(:each).and_yield(sample_direct_messages[0].to_json)
211
211
  yielded_client = nil
212
212
  @client.on_direct_message do |_, client|
213
213
  yielded_client = client
@@ -217,23 +217,23 @@ describe TweetStream::Client do
217
217
  end
218
218
 
219
219
  it "calls on_error if a non-hash response is received" do
220
- @stream.should_receive(:each).and_yield('["favorited"]')
220
+ expect(@stream).to receive(:each).and_yield('["favorited"]')
221
221
  @client.on_error do |message|
222
222
  expect(message).to eq('Unexpected JSON object in stream: ["favorited"]')
223
223
  end.track('abc')
224
224
  end
225
225
 
226
226
  it "calls on_error if a json parse error occurs" do
227
- @stream.should_receive(:each).and_yield("{'a_key':}")
227
+ expect(@stream).to receive(:each).and_yield("{'a_key':}")
228
228
  @client.on_error do |message|
229
- expect(message).to eq("Yajl::ParseError occured in stream: {'a_key':}")
229
+ expect(message).to eq("MultiJson::DecodeError occured in stream: {'a_key':}")
230
230
  end.track('abc')
231
231
  end
232
232
  end
233
233
 
234
234
  describe "#on_error" do
235
235
  it "passes the message on to the error block" do
236
- @stream.should_receive(:on_error).and_yield('Uh oh')
236
+ expect(@stream).to receive(:on_error).and_yield('Uh oh')
237
237
  @client.on_error do |m|
238
238
  expect(m).to eq('Uh oh')
239
239
  end.track('abc')
@@ -251,7 +251,7 @@ describe TweetStream::Client do
251
251
 
252
252
  describe "#on_max_reconnects" do
253
253
  it "raises a ReconnectError" do
254
- @stream.should_receive(:on_max_reconnects).and_yield(30, 20)
254
+ expect(@stream).to receive(:on_max_reconnects).and_yield(30, 20)
255
255
  expect(lambda{ @client.track('abc') }).to raise_error(TweetStream::ReconnectError, "Failed to reconnect after 20 tries.")
256
256
  end
257
257
  end
@@ -260,64 +260,64 @@ describe TweetStream::Client do
260
260
  describe "API methods" do
261
261
  %w(firehose retweet sample links).each do |method|
262
262
  it "##{method} should make a call to start with \"statuses/#{method}\"" do
263
- @client.should_receive(:start).once.with('/1.1/statuses/' + method + '.json', {})
263
+ expect(@client).to receive(:start).once.with('/1.1/statuses/' + method + '.json', {})
264
264
  @client.send(method)
265
265
  end
266
266
  end
267
267
 
268
268
  describe "#filter" do
269
269
  it "makes a call to 'statuses/filter' with the query params provided" do
270
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :follow => 123, :method => :post)
270
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :follow => 123, :method => :post)
271
271
  @client.filter(:follow => 123)
272
272
  end
273
273
  it "makes a call to 'statuses/filter' with the query params provided longitude/latitude pairs, separated by commas " do
274
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41', :method => :post)
274
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41', :method => :post)
275
275
  @client.filter(:locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41')
276
276
  end
277
277
  end
278
278
 
279
279
  describe "#follow" do
280
280
  it "makes a call to start with 'statuses/filter' and a follow query parameter" do
281
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :follow => [123], :method => :post)
281
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :follow => [123], :method => :post)
282
282
  @client.follow(123)
283
283
  end
284
284
 
285
285
  it "comma-joins multiple arguments" do
286
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :follow => [123,456], :method => :post)
286
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :follow => [123,456], :method => :post)
287
287
  @client.follow(123, 456)
288
288
  end
289
289
  end
290
290
 
291
291
  describe "#locations" do
292
292
  it "calls #start with 'statuses/filter' with the query params provided longitude/latitude pairs" do
293
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :method => :post)
293
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :method => :post)
294
294
  @client.locations('-122.75,36.8,-121.75,37.8,-74,40,-73,41')
295
295
  end
296
296
 
297
297
  it "calls #start with 'statuses/filter' with the query params provided longitude/latitude pairs and additional filter" do
298
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :track => 'rock', :method => :post)
298
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :track => 'rock', :method => :post)
299
299
  @client.locations('-122.75,36.8,-121.75,37.8,-74,40,-73,41', :track => 'rock')
300
300
  end
301
301
  end
302
302
 
303
303
  describe "#track" do
304
304
  it "makes a call to start with 'statuses/filter' and a track query parameter" do
305
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :track => ['test'], :method => :post)
305
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :track => ['test'], :method => :post)
306
306
  @client.track('test')
307
307
  end
308
308
 
309
309
  it "comma-joins multiple arguments" do
310
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :track => ['foo', 'bar', 'baz'], :method => :post)
310
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :track => ['foo', 'bar', 'baz'], :method => :post)
311
311
  @client.track('foo', 'bar', 'baz')
312
312
  end
313
313
 
314
314
  it "comma-joins an array of arguments" do
315
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :track => [['foo','bar','baz']], :method => :post)
315
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :track => [['foo','bar','baz']], :method => :post)
316
316
  @client.track(['foo','bar','baz'])
317
317
  end
318
318
 
319
319
  it "calls #start with 'statuses/filter' and the provided queries" do
320
- @client.should_receive(:start).once.with('/1.1/statuses/filter.json', :track => ['rock'], :method => :post)
320
+ expect(@client).to receive(:start).once.with('/1.1/statuses/filter.json', :track => ['rock'], :method => :post)
321
321
  @client.track('rock')
322
322
  end
323
323
  end
@@ -339,12 +339,12 @@ describe TweetStream::Client do
339
339
 
340
340
  describe "#stop" do
341
341
  it "calls EventMachine::stop_event_loop" do
342
- EventMachine.should_receive :stop_event_loop
342
+ expect(EventMachine).to receive(:stop_event_loop)
343
343
  expect(TweetStream::Client.new.stop).to be_nil
344
344
  end
345
345
 
346
346
  it "returns the last status yielded" do
347
- EventMachine.should_receive :stop_event_loop
347
+ expect(EventMachine).to receive(:stop_event_loop)
348
348
  client = TweetStream::Client.new
349
349
  client.send(:instance_variable_set, :@last_status, {})
350
350
  expect(client.stop).to eq({})
@@ -353,14 +353,14 @@ describe TweetStream::Client do
353
353
 
354
354
  describe "#close_connection" do
355
355
  it "does not call EventMachine::stop_event_loop" do
356
- EventMachine.should_not_receive :stop_event_loop
356
+ expect(EventMachine).not_to receive(:stop_event_loop)
357
357
  expect(TweetStream::Client.new.close_connection).to be_nil
358
358
  end
359
359
  end
360
360
 
361
361
  describe "#stop_stream" do
362
362
  before(:each) do
363
- @stream = stub("EM::Twitter::Client",
363
+ @stream = double("EM::Twitter::Client",
364
364
  :connect => true,
365
365
  :unbind => true,
366
366
  :each => true,
@@ -373,18 +373,18 @@ describe TweetStream::Client do
373
373
  :on_enhance_your_calm => true,
374
374
  :stop => true
375
375
  )
376
- EM::Twitter::Client.stub!(:connect).and_return(@stream)
376
+ allow(EM::Twitter::Client).to receive(:connect).and_return(@stream)
377
377
  @client = TweetStream::Client.new
378
378
  @client.connect('/')
379
379
  end
380
380
 
381
381
  it "calls stream.stop to cleanly stop the current stream" do
382
- @stream.should_receive(:stop)
382
+ expect(@stream).to receive(:stop)
383
383
  @client.stop_stream
384
384
  end
385
385
 
386
386
  it "does not stop eventmachine" do
387
- EventMachine.should_not_receive :stop_event_loop
387
+ expect(EventMachine).not_to receive(:stop_event_loop)
388
388
  @client.stop_stream
389
389
  end
390
390
  end