tweetstream 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

@@ -10,55 +10,55 @@ describe TweetStream::Client do
10
10
  end
11
11
  @client = TweetStream::Client.new
12
12
 
13
- @stream = double("EM::Twitter::Client",
14
- :connect => true,
15
- :unbind => true,
16
- :each => true,
17
- :on_error => true,
18
- :on_max_reconnects => true,
19
- :on_reconnect => true,
20
- :connection_completed => true,
21
- :on_no_data_received => true,
22
- :on_unauthorized => true,
23
- :on_enhance_your_calm => true
13
+ @stream = double('EM::Twitter::Client',
14
+ :connect => true,
15
+ :unbind => true,
16
+ :each => true,
17
+ :on_error => true,
18
+ :on_max_reconnects => true,
19
+ :on_reconnect => true,
20
+ :connection_completed => true,
21
+ :on_no_data_received => true,
22
+ :on_unauthorized => true,
23
+ :on_enhance_your_calm => true
24
24
  )
25
25
  allow(EM).to receive(:run).and_yield
26
26
  allow(EM::Twitter::Client).to receive(:connect).and_return(@stream)
27
27
  end
28
28
 
29
- describe "User Stream support" do
30
- context "when calling #userstream" do
31
- it "sends the userstream host" do
32
- expect(EM::Twitter::Client).to receive(:connect).with(hash_including(:host => "userstream.twitter.com")).and_return(@stream)
29
+ describe 'User Stream support' do
30
+ context 'when calling #userstream' do
31
+ it 'sends the userstream host' do
32
+ expect(EM::Twitter::Client).to receive(:connect).with(hash_including(:host => 'userstream.twitter.com')).and_return(@stream)
33
33
  @client.userstream
34
34
  end
35
35
 
36
- it "uses the userstream uri" do
37
- expect(@client).to receive(:start).once.with("/1.1/user.json", an_instance_of(Hash)).and_return(@stream)
36
+ it 'uses the userstream uri' do
37
+ expect(@client).to receive(:start).once.with('/1.1/user.json', an_instance_of(Hash)).and_return(@stream)
38
38
  @client.userstream
39
39
  end
40
40
 
41
41
  it "supports :replies => 'all'" do
42
- expect(@client).to receive(:start).once.with("/1.1/user.json", hash_including(:replies => 'all')).and_return(@stream)
42
+ expect(@client).to receive(:start).once.with('/1.1/user.json', hash_including(:replies => 'all')).and_return(@stream)
43
43
  @client.userstream(:replies => 'all')
44
44
  end
45
45
 
46
46
  it "supports :stall_warnings => 'true'" do
47
- expect(@client).to receive(:start).once.with("/1.1/user.json", hash_including(:stall_warnings => 'true')).and_return(@stream)
47
+ expect(@client).to receive(:start).once.with('/1.1/user.json', hash_including(:stall_warnings => 'true')).and_return(@stream)
48
48
  @client.userstream(:stall_warnings => 'true')
49
49
  end
50
50
 
51
51
  it "supports :with => 'followings'" do
52
- expect(@client).to receive(:start).once.with("/1.1/user.json", hash_including(:with => 'followings')).and_return(@stream)
52
+ expect(@client).to receive(:start).once.with('/1.1/user.json', hash_including(:with => 'followings')).and_return(@stream)
53
53
  @client.userstream(:with => 'followings')
54
54
  end
55
55
 
56
56
  it "supports :with => 'user'" do
57
- expect(@client).to receive(:start).once.with("/1.1/user.json", hash_including(:with => 'user')).and_return(@stream)
57
+ expect(@client).to receive(:start).once.with('/1.1/user.json', hash_including(:with => 'user')).and_return(@stream)
58
58
  @client.userstream(:with => 'user')
59
59
  end
60
60
 
61
- it "supports event callbacks" do
61
+ it 'supports event callbacks' do
62
62
  event = nil
63
63
  expect(@stream).to receive(:each).and_yield(fixture('favorite.json'))
64
64
  @client.on_event(:favorite) do |e|
@@ -1,26 +1,26 @@
1
1
  require 'helper'
2
2
 
3
3
  describe TweetStream::Daemon do
4
- describe ".new" do
5
- it "initializes with no arguments" do
4
+ describe '.new' do
5
+ it 'initializes with no arguments' do
6
6
  client = TweetStream::Daemon.new
7
7
  expect(client).to be_kind_of(TweetStream::Client)
8
8
  end
9
9
 
10
- it "initializes with defaults" do
10
+ it 'initializes with defaults' do
11
11
  client = TweetStream::Daemon.new
12
12
  expect(client.app_name).to eq(TweetStream::Daemon::DEFAULT_NAME)
13
13
  expect(client.daemon_options).to eq(TweetStream::Daemon::DEFAULT_OPTIONS)
14
14
  end
15
15
 
16
- it "initializes with an app_name" do
16
+ it 'initializes with an app_name' do
17
17
  client = TweetStream::Daemon.new('tweet_tracker')
18
18
  expect(client.app_name).to eq('tweet_tracker')
19
19
  end
20
20
  end
21
21
 
22
- describe "#start" do
23
- it "starts the daemon" do
22
+ describe '#start' do
23
+ it 'starts the daemon' do
24
24
  client = TweetStream::Daemon.new
25
25
  expect(Daemons).to receive(:run_proc).once
26
26
  client.track('intridea')
@@ -5,8 +5,8 @@ describe TweetStream::SiteStreamClient do
5
5
  let(:config_uri) { '/2b/site/c/1_1_54e345d655ee3e8df359ac033648530bfbe26c5g' }
6
6
  let(:client) { TweetStream::SiteStreamClient.new(config_uri) }
7
7
 
8
- describe "initialization" do
9
- context "with module configuration" do
8
+ describe 'initialization' do
9
+ context 'with module configuration' do
10
10
 
11
11
  before do
12
12
  TweetStream.configure do |config|
@@ -20,7 +20,7 @@ describe TweetStream::SiteStreamClient do
20
20
  TweetStream.reset
21
21
  end
22
22
 
23
- it "inherits module configuration" do
23
+ it 'inherits module configuration' do
24
24
  api = TweetStream::SiteStreamClient.new('/config_uri')
25
25
  keys.each do |key|
26
26
  expect(api.send(key)).to eq(key)
@@ -28,7 +28,7 @@ describe TweetStream::SiteStreamClient do
28
28
  end
29
29
  end
30
30
 
31
- context "with class configuration" do
31
+ context 'with class configuration' do
32
32
  let(:configuration) do
33
33
  {
34
34
  :consumer_key => 'CK',
@@ -38,8 +38,8 @@ describe TweetStream::SiteStreamClient do
38
38
  }
39
39
  end
40
40
 
41
- context "during initialization" do
42
- it "overrides module configuration" do
41
+ context 'during initialization' do
42
+ it 'overrides module configuration' do
43
43
  api = TweetStream::SiteStreamClient.new('/config_uri', configuration)
44
44
  keys.each do |key|
45
45
  expect(api.send(key)).to eq(configuration[key])
@@ -47,8 +47,8 @@ describe TweetStream::SiteStreamClient do
47
47
  end
48
48
  end
49
49
 
50
- context "after initilization" do
51
- it "overrides module configuration after initialization" do
50
+ context 'after initilization' do
51
+ it 'overrides module configuration after initialization' do
52
52
  api = TweetStream::SiteStreamClient.new('/config_uri')
53
53
  configuration.each do |key, value|
54
54
  api.send("#{key}=", value)
@@ -61,30 +61,30 @@ describe TweetStream::SiteStreamClient do
61
61
  end
62
62
  end
63
63
 
64
- describe "#on_error" do
65
- it "stores the on_error proc" do
64
+ describe '#on_error' do
65
+ it 'stores the on_error proc' do
66
66
  client = TweetStream::SiteStreamClient.new('/config_uri')
67
67
  client.on_error { puts 'hi' }
68
68
  expect(client.on_error).to be_kind_of(Proc)
69
69
  end
70
70
  end
71
71
 
72
- describe "#info" do
73
- context "success" do
74
- it "returns the information hash" do
72
+ describe '#info' do
73
+ context 'success' do
74
+ it 'returns the information hash' do
75
75
  stub_request(:get, "https://sitestream.twitter.com#{config_uri}/info.json").
76
76
  to_return(:status => 200, :body => fixture('info.json'), :headers => {})
77
77
  stream_info = nil
78
78
 
79
79
  EM.run_block do
80
- client.info { |info| stream_info = info}
80
+ client.info { |info| stream_info = info }
81
81
  end
82
82
  expect(stream_info).to be_kind_of(Hash)
83
83
  end
84
84
  end
85
85
 
86
- context "failure" do
87
- it "invokes the on_error callback" do
86
+ context 'failure' do
87
+ it 'invokes the on_error callback' do
88
88
  stub_request(:get, "https://sitestream.twitter.com#{config_uri}/info.json").
89
89
  to_return(:status => 401, :body => '', :headers => {})
90
90
  called = false
@@ -99,142 +99,142 @@ describe TweetStream::SiteStreamClient do
99
99
  end
100
100
  end
101
101
 
102
- describe "#add_user" do
103
- context "success" do
104
- it "calls a block (if passed one)" do
102
+ describe '#add_user' do
103
+ context 'success' do
104
+ it 'calls a block (if passed one)' do
105
105
  stub_request(:post, "https://sitestream.twitter.com#{config_uri}/add_user.json").
106
106
  to_return(:status => 200, :body => '', :headers => {})
107
107
  called = false
108
108
 
109
109
  EM.run_block do
110
- client.add_user(12345) { called = true }
110
+ client.add_user(123) { called = true }
111
111
  end
112
112
  expect(called).to be_true
113
113
  end
114
114
  end
115
115
 
116
- context "failure" do
117
- it "invokes the on_error callback" do
116
+ context 'failure' do
117
+ it 'invokes the on_error callback' do
118
118
  stub_request(:post, "https://sitestream.twitter.com#{config_uri}/add_user.json").
119
119
  to_return(:status => 401, :body => '', :headers => {})
120
120
  called = false
121
121
 
122
122
  EM.run_block do
123
123
  client.on_error { called = true }
124
- client.add_user(12345) { |info| info }
124
+ client.add_user(123) { |info| info }
125
125
  end
126
126
  expect(called).to be_true
127
127
  end
128
128
  end
129
129
 
130
- it "accepts an array of user_ids" do
130
+ it 'accepts an array of user_ids' do
131
131
  conn = double('Connection')
132
132
  expect(conn).to receive(:post).
133
- with(:path => "#{config_uri}/add_user.json", :body => { 'user_id' => '1234,5678' }).
133
+ with(:path => "#{config_uri}/add_user.json", :body => {'user_id' => '1234,5678'}).
134
134
  and_return(FakeHttp.new)
135
135
  allow(client).to receive(:connection) { conn }
136
- client.add_user(['1234','5678'])
136
+ client.add_user(%w[1234 5678])
137
137
  end
138
138
 
139
- describe "accepts a single user_id as" do
139
+ describe 'accepts a single user_id as' do
140
140
  before :each do
141
141
  conn = double('Connection')
142
142
  expect(conn).to receive(:post).
143
- with(:path => "#{config_uri}/add_user.json", :body => { 'user_id' => '1234' }).
143
+ with(:path => "#{config_uri}/add_user.json", :body => {'user_id' => '1234'}).
144
144
  and_return(FakeHttp.new)
145
145
  allow(client).to receive(:connection) { conn }
146
146
  end
147
147
 
148
- it "a string" do
148
+ it 'a string' do
149
149
  client.add_user('1234')
150
150
  end
151
151
 
152
- it "an integer" do
152
+ it 'an integer' do
153
153
  client.add_user(1234)
154
154
  end
155
155
  end
156
156
 
157
157
  end
158
158
 
159
- describe "#remove_user" do
160
- context "success" do
161
- it "calls a block (if passed one)" do
159
+ describe '#remove_user' do
160
+ context 'success' do
161
+ it 'calls a block (if passed one)' do
162
162
  stub_request(:post, "https://sitestream.twitter.com#{config_uri}/remove_user.json").
163
163
  to_return(:status => 200, :body => '', :headers => {})
164
164
  called = false
165
165
 
166
166
  EM.run_block do
167
- client.remove_user(12345) { called = true }
167
+ client.remove_user(123) { called = true }
168
168
  end
169
169
  expect(called).to be_true
170
170
  end
171
171
  end
172
172
 
173
- context "failure" do
174
- it "invokes the on_error callback" do
173
+ context 'failure' do
174
+ it 'invokes the on_error callback' do
175
175
  stub_request(:post, "https://sitestream.twitter.com#{config_uri}/remove_user.json").
176
176
  to_return(:status => 401, :body => '', :headers => {})
177
177
  called = false
178
178
 
179
179
  EM.run_block do
180
180
  client.on_error { called = true }
181
- client.remove_user(12345) { |info| info }
181
+ client.remove_user(123) { |info| info }
182
182
  end
183
183
  expect(called).to be_true
184
184
  end
185
185
  end
186
186
 
187
- it "accepts an array of user_ids" do
187
+ it 'accepts an array of user_ids' do
188
188
  conn = double('Connection')
189
189
  expect(conn).to receive(:post).
190
- with(:path => "#{config_uri}/remove_user.json", :body => { 'user_id' => '1234,5678' }).
190
+ with(:path => "#{config_uri}/remove_user.json", :body => {'user_id' => '1234,5678'}).
191
191
  and_return(FakeHttp.new)
192
192
  allow(client).to receive(:connection) { conn }
193
- client.remove_user(['1234','5678'])
193
+ client.remove_user(%w[1234 5678])
194
194
  end
195
195
 
196
- describe "accepts a single user_id as" do
196
+ describe 'accepts a single user_id as' do
197
197
  before :each do
198
198
  conn = double('Connection')
199
199
  expect(conn).to receive(:post).
200
- with(:path => "#{config_uri}/remove_user.json", :body => { 'user_id' => '1234' }).
200
+ with(:path => "#{config_uri}/remove_user.json", :body => {'user_id' => '1234'}).
201
201
  and_return(FakeHttp.new)
202
202
  allow(client).to receive(:connection) { conn }
203
203
  end
204
204
 
205
- it "a string" do
205
+ it 'a string' do
206
206
  client.remove_user('1234')
207
207
  end
208
208
 
209
- it "an integer" do
209
+ it 'an integer' do
210
210
  client.remove_user(1234)
211
211
  end
212
212
  end
213
213
  end
214
214
 
215
- describe "#friends_ids" do
216
- context "success" do
217
- it "returns the information hash" do
215
+ describe '#friends_ids' do
216
+ context 'success' do
217
+ it 'returns the information hash' do
218
218
  stub_request(:post, "https://sitestream.twitter.com#{config_uri}/friends/ids.json").
219
219
  to_return(:status => 200, :body => fixture('ids.json'), :headers => {})
220
220
  stream_info = nil
221
221
 
222
222
  EM.run_block do
223
- client.friends_ids(12345) { |info| stream_info = info }
223
+ client.friends_ids(123) { |info| stream_info = info }
224
224
  end
225
225
  expect(stream_info).to be_kind_of(Hash)
226
226
  end
227
227
  end
228
228
 
229
- context "failure" do
230
- it "invokes the on_error callback" do
229
+ context 'failure' do
230
+ it 'invokes the on_error callback' do
231
231
  stub_request(:post, "https://sitestream.twitter.com#{config_uri}/friends/ids.json").
232
232
  to_return(:status => 401, :body => '', :headers => {})
233
233
  called = false
234
234
 
235
235
  EM.run_block do
236
236
  client.on_error { called = true }
237
- client.friends_ids(12345) { |info| info }
237
+ client.friends_ids(123) { |info| info }
238
238
  end
239
239
  expect(called).to be_true
240
240
  end
@@ -2,96 +2,96 @@ require 'helper'
2
2
 
3
3
  describe TweetStream do
4
4
 
5
- context "when delegating to a client" do
5
+ context 'when delegating to a client' do
6
6
  before do
7
- @stream = double("EM::Twitter::Client",
8
- :connect => true,
9
- :unbind => true,
10
- :each_item => true,
11
- :on_error => true,
12
- :on_max_reconnects => true,
13
- :on_reconnect => true,
14
- :connection_completed => true,
15
- :on_no_data_received => true,
16
- :on_unauthorized => true,
17
- :on_enhance_your_calm => true
7
+ @stream = double('EM::Twitter::Client',
8
+ :connect => true,
9
+ :unbind => true,
10
+ :each_item => true,
11
+ :on_error => true,
12
+ :on_max_reconnects => true,
13
+ :on_reconnect => true,
14
+ :connection_completed => true,
15
+ :on_no_data_received => true,
16
+ :on_unauthorized => true,
17
+ :on_enhance_your_calm => true
18
18
  )
19
19
  allow(EM).to receive(:run).and_yield
20
20
  allow(EM::Twitter::Client).to receive(:connect).and_return(@stream)
21
21
  end
22
22
 
23
- it "returns the same results as a client" do
23
+ it 'returns the same results as a client' do
24
24
  expect(MultiJson).to receive(:decode).and_return({})
25
25
  expect(@stream).to receive(:each).and_yield(sample_tweets[0].to_json)
26
- TweetStream.track('abc','def')
26
+ TweetStream.track('abc', 'def')
27
27
  end
28
28
  end
29
29
 
30
- describe ".new" do
31
- it "is a TweetStream::Client" do
30
+ describe '.new' do
31
+ it 'is a TweetStream::Client' do
32
32
  expect(TweetStream.new).to be_a TweetStream::Client
33
33
  end
34
34
  end
35
35
 
36
- describe ".respond_to?" do
37
- it "takes an optional argument" do
36
+ describe '.respond_to?' do
37
+ it 'takes an optional argument' do
38
38
  expect(TweetStream.respond_to?(:new, true)).to be_true
39
39
  end
40
40
  end
41
41
 
42
- describe ".username" do
43
- it "returns the default username" do
42
+ describe '.username' do
43
+ it 'returns the default username' do
44
44
  expect(TweetStream.username).to eq(TweetStream::Configuration::DEFAULT_USERNAME)
45
45
  end
46
46
  end
47
47
 
48
- describe ".username=" do
49
- it "sets the username" do
48
+ describe '.username=' do
49
+ it 'sets the username' do
50
50
  TweetStream.username = 'jack'
51
51
  expect(TweetStream.username).to eq('jack')
52
52
  end
53
53
  end
54
54
 
55
- describe ".password" do
56
- it "returns the default password" do
55
+ describe '.password' do
56
+ it 'returns the default password' do
57
57
  expect(TweetStream.password).to eq(TweetStream::Configuration::DEFAULT_PASSWORD)
58
58
  end
59
59
  end
60
60
 
61
- describe ".password=" do
62
- it "sets the password" do
61
+ describe '.password=' do
62
+ it 'sets the password' do
63
63
  TweetStream.password = 'passw0rd'
64
64
  expect(TweetStream.password).to eq('passw0rd')
65
65
  end
66
66
  end
67
67
 
68
- describe ".auth_method" do
69
- it "shold return the default auth method" do
68
+ describe '.auth_method' do
69
+ it 'shold return the default auth method' do
70
70
  expect(TweetStream.auth_method).to eq(TweetStream::Configuration::DEFAULT_AUTH_METHOD)
71
71
  end
72
72
  end
73
73
 
74
- describe ".auth_method=" do
75
- it "sets the auth method" do
74
+ describe '.auth_method=' do
75
+ it 'sets the auth method' do
76
76
  TweetStream.auth_method = :basic
77
77
  expect(TweetStream.auth_method).to eq(:basic)
78
78
  end
79
79
  end
80
80
 
81
- describe ".user_agent" do
82
- it "returns the default user agent" do
81
+ describe '.user_agent' do
82
+ it 'returns the default user agent' do
83
83
  expect(TweetStream.user_agent).to eq(TweetStream::Configuration::DEFAULT_USER_AGENT)
84
84
  end
85
85
  end
86
86
 
87
- describe ".user_agent=" do
88
- it "sets the user_agent" do
87
+ describe '.user_agent=' do
88
+ it 'sets the user_agent' do
89
89
  TweetStream.user_agent = 'Custom User Agent'
90
90
  expect(TweetStream.user_agent).to eq('Custom User Agent')
91
91
  end
92
92
  end
93
93
 
94
- describe ".configure" do
94
+ describe '.configure' do
95
95
  TweetStream::Configuration::VALID_OPTIONS_KEYS.each do |key|
96
96
  it "sets the #{key}" do
97
97
  TweetStream.configure do |config|
@@ -102,14 +102,14 @@ describe TweetStream do
102
102
  end
103
103
  end
104
104
 
105
- describe ".options" do
106
- it "returns the configuration as a hash" do
105
+ describe '.options' do
106
+ it 'returns the configuration as a hash' do
107
107
  expect(TweetStream.options).to be_kind_of(Hash)
108
108
  end
109
109
  end
110
110
 
111
- describe ".oauth_options" do
112
- it "returns the oauth configuration as a hash" do
111
+ describe '.oauth_options' do
112
+ it 'returns the oauth configuration as a hash' do
113
113
  expect(TweetStream.oauth_options).to be_kind_of(Hash)
114
114
  end
115
115
  end
@@ -122,7 +122,7 @@ describe TweetStream do
122
122
 
123
123
  describe '.proxy=' do
124
124
  it 'sets the proxy' do
125
- TweetStream.proxy = { :uri => 'http://someproxy:8081' }
125
+ TweetStream.proxy = {:uri => 'http://someproxy:8081'}
126
126
  expect(TweetStream.proxy).to be_kind_of(Hash)
127
127
  end
128
128
  end