pusher 0.14.5 → 0.14.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bd67ccabffeb24e369e09b592b06a9991c4795d
4
- data.tar.gz: 035e6c2def599b1ce8a6cd12897a908a011fc1fa
3
+ metadata.gz: 6a05ddf26ee71f3e0a3d751b2889d3d1495251db
4
+ data.tar.gz: c9fb9b3cde9ba84f0142338f75976a48d589fd4e
5
5
  SHA512:
6
- metadata.gz: da4f65dc4b9cbd5d37020d26bde929381413b3285346f5a9979d664967fc1a1a606ee84572dd1acf8bd9fb70aa5626f996383aa20ff91949dc6120242c35e8bc
7
- data.tar.gz: 63ddd45053e53489dcc2759eabf4ae76b7732cc37fb0ad72866716aba87473971702f43d036fffde82d220abf87890b83395c2e09ce07c52c67f414173fcab35
6
+ metadata.gz: cb0866fb85465274cd61ecbe4ff0aa19ac94d0c20f783838e268909b2ae0d43d9ebc16778a8a1ec24589e1c1441c347d45d84079ac6dbc3f1ef3a6e8da26fafe
7
+ data.tar.gz: 129331534bbe57502166e569978701dc21bad9f805f3d06c2c822ac0ea80c12f290f5366cc525fd31ca91ac3a088119460127a197b9c0e2f85cc2b5b96eaf7c6
@@ -1,3 +1,7 @@
1
+ 0.14.6 / 2015-09-29
2
+ ==================
3
+ * Updated to use the `pusher-signature` gem instead of `signature`.
4
+ This resolves namespace related issues.
1
5
 
2
6
  0.14.5 / 2015-05-11
3
7
  ==================
data/README.md CHANGED
@@ -139,7 +139,7 @@ There are two main reasons for using the `_async` methods:
139
139
 
140
140
  Asynchronous calls are supported either by using an event loop (eventmachine, preferred), or via a thread.
141
141
 
142
- The following methods are available (in each case the calling iterface matches the non-async version):
142
+ The following methods are available (in each case the calling interface matches the non-async version):
143
143
 
144
144
  * `Pusher.get_async`
145
145
  * `Pusher.post_async`
@@ -1,4 +1,4 @@
1
- require 'signature'
1
+ require 'pusher-signature'
2
2
 
3
3
  module Pusher
4
4
  class Client
@@ -30,7 +30,7 @@ module Pusher
30
30
 
31
31
  # @private Returns the authentication token for the client
32
32
  def authentication_token
33
- Signature::Token.new(@key, @secret)
33
+ Pusher::Signature::Token.new(@key, @secret)
34
34
  end
35
35
 
36
36
  # @private Builds a url for this app, optionally appending a path
@@ -1,4 +1,4 @@
1
- require 'signature'
1
+ require 'pusher-signature'
2
2
  require 'digest/md5'
3
3
  require 'multi_json'
4
4
 
@@ -16,7 +16,7 @@ module Pusher
16
16
  @head['Content-Type'] = 'application/json'
17
17
  end
18
18
 
19
- request = Signature::Request.new(verb.to_s.upcase, uri.path, params)
19
+ request = Pusher::Signature::Request.new(verb.to_s.upcase, uri.path, params)
20
20
  request.sign(client.authentication_token)
21
21
  @params = request.signed_params
22
22
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "pusher"
6
- s.version = "0.14.5"
6
+ s.version = "0.14.6"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Pusher"]
9
9
  s.email = ["support@pusher.com"]
@@ -13,11 +13,11 @@ Gem::Specification.new do |s|
13
13
  s.license = "MIT"
14
14
 
15
15
  s.add_dependency "multi_json", "~> 1.0"
16
- s.add_dependency 'signature', "~> 0.1.8"
16
+ s.add_dependency 'pusher-signature', "~> 0.1.8"
17
17
  s.add_dependency "httpclient", "~> 2.5"
18
18
  s.add_dependency "jruby-openssl" if defined?(JRUBY_VERSION)
19
19
 
20
- s.add_development_dependency "rspec", "~> 2.0"
20
+ s.add_development_dependency "rspec", "~> 3.0"
21
21
  s.add_development_dependency "webmock"
22
22
  s.add_development_dependency "em-http-request", "~> 1.1.0"
23
23
  s.add_development_dependency "rake"
@@ -28,7 +28,7 @@ describe Pusher::Channel do
28
28
 
29
29
  describe '#trigger!' do
30
30
  it "should use @client.trigger internally" do
31
- @client.should_receive(:trigger)
31
+ expect(@client).to receive(:trigger)
32
32
  @channel.trigger('new_event', 'Some data')
33
33
  end
34
34
  end
@@ -37,16 +37,16 @@ describe Pusher::Channel do
37
37
  it "should log failure if error raised in http call" do
38
38
  stub_post_to_raise(HTTPClient::BadResponseError)
39
39
 
40
- Pusher.logger.should_receive(:error).with("Exception from WebMock (HTTPClient::BadResponseError) (Pusher::HTTPError)")
41
- Pusher.logger.should_receive(:debug) #backtrace
40
+ expect(Pusher.logger).to receive(:error).with("Exception from WebMock (HTTPClient::BadResponseError) (Pusher::HTTPError)")
41
+ expect(Pusher.logger).to receive(:debug) #backtrace
42
42
  channel = Pusher::Channel.new(@client.url, 'test_channel', @client)
43
43
  channel.trigger('new_event', 'Some data')
44
44
  end
45
45
 
46
46
  it "should log failure if Pusher returns an error response" do
47
47
  stub_post 401, "some signature info"
48
- Pusher.logger.should_receive(:error).with("some signature info (Pusher::AuthenticationError)")
49
- Pusher.logger.should_receive(:debug) #backtrace
48
+ expect(Pusher.logger).to receive(:error).with("some signature info (Pusher::AuthenticationError)")
49
+ expect(Pusher.logger).to receive(:debug) #backtrace
50
50
  channel = Pusher::Channel.new(@client.url, 'test_channel', @client)
51
51
  channel.trigger('new_event', 'Some data')
52
52
  end
@@ -54,30 +54,30 @@ describe Pusher::Channel do
54
54
 
55
55
  describe "#initialization" do
56
56
  it "should not be too long" do
57
- lambda { @client['b'*201] }.should raise_error(Pusher::Error)
57
+ expect { @client['b'*201] }.to raise_error(Pusher::Error)
58
58
  end
59
59
 
60
60
  it "should not use bad characters" do
61
- lambda { @client['*^!±`/""'] }.should raise_error(Pusher::Error)
61
+ expect { @client['*^!±`/""'] }.to raise_error(Pusher::Error)
62
62
  end
63
63
  end
64
64
 
65
65
  describe "#trigger_async" do
66
66
  it "should use @client.trigger_async internally" do
67
- @client.should_receive(:trigger_async)
67
+ expect(@client).to receive(:trigger_async)
68
68
  @channel.trigger_async('new_event', 'Some data')
69
69
  end
70
70
  end
71
71
 
72
72
  describe '#info' do
73
73
  it "should call the Client#channel_info" do
74
- @client.should_receive(:get).with("/channels/mychannel", anything)
74
+ expect(@client).to receive(:get).with("/channels/mychannel", anything)
75
75
  @channel = @client['mychannel']
76
76
  @channel.info
77
77
  end
78
78
 
79
79
  it "should assemble the requested attributes into the info option" do
80
- @client.should_receive(:get).with(anything, {
80
+ expect(@client).to receive(:get).with(anything, {
81
81
  :info => "user_count,connection_count"
82
82
  })
83
83
  @channel = @client['presence-foo']
@@ -87,7 +87,7 @@ describe Pusher::Channel do
87
87
 
88
88
  describe '#users' do
89
89
  it "should call the Client#channel_users" do
90
- @client.should_receive(:get).with("/channels/presence-mychannel/users").and_return({:users => {'id' => '4'}})
90
+ expect(@client).to receive(:get).with("/channels/presence-mychannel/users").and_return({:users => {'id' => '4'}})
91
91
  @channel = @client['presence-mychannel']
92
92
  @channel.users
93
93
  end
@@ -101,28 +101,28 @@ describe Pusher::Channel do
101
101
  it "should return an authentication string given a socket id" do
102
102
  auth = @channel.authentication_string('1.1')
103
103
 
104
- auth.should == '12345678900000001:02259dff9a2a3f71ea8ab29ac0c0c0ef7996c8f3fd3702be5533f30da7d7fed4'
104
+ expect(auth).to eq('12345678900000001:02259dff9a2a3f71ea8ab29ac0c0c0ef7996c8f3fd3702be5533f30da7d7fed4')
105
105
  end
106
106
 
107
107
  it "should raise error if authentication is invalid" do
108
108
  [nil, ''].each do |invalid|
109
- authentication_string(invalid).should raise_error Pusher::Error
109
+ expect(authentication_string(invalid)).to raise_error Pusher::Error
110
110
  end
111
111
  end
112
112
 
113
113
  describe 'with extra string argument' do
114
114
  it 'should be a string or nil' do
115
- authentication_string('1.1', 123).should raise_error Pusher::Error
116
- authentication_string('1.1', {}).should raise_error Pusher::Error
115
+ expect(authentication_string('1.1', 123)).to raise_error Pusher::Error
116
+ expect(authentication_string('1.1', {})).to raise_error Pusher::Error
117
117
 
118
- authentication_string('1.1', 'boom').should_not raise_error
119
- authentication_string('1.1', nil).should_not raise_error
118
+ expect(authentication_string('1.1', 'boom')).not_to raise_error
119
+ expect(authentication_string('1.1', nil)).not_to raise_error
120
120
  end
121
121
 
122
122
  it "should return an authentication string given a socket id and custom args" do
123
123
  auth = @channel.authentication_string('1.1', 'foobar')
124
124
 
125
- auth.should == "12345678900000001:#{hmac(@client.secret, "1.1:test_channel:foobar")}"
125
+ expect(auth).to eq("12345678900000001:#{hmac(@client.secret, "1.1:test_channel:foobar")}")
126
126
  end
127
127
  end
128
128
  end
@@ -133,36 +133,36 @@ describe Pusher::Channel do
133
133
  end
134
134
 
135
135
  it 'should return a hash with signature including custom data and data as json string' do
136
- MultiJson.stub(:encode).with(@custom_data).and_return 'a json string'
136
+ allow(MultiJson).to receive(:encode).with(@custom_data).and_return 'a json string'
137
137
 
138
138
  response = @channel.authenticate('1.1', @custom_data)
139
139
 
140
- response.should == {
140
+ expect(response).to eq({
141
141
  :auth => "12345678900000001:#{hmac(@client.secret, "1.1:test_channel:a json string")}",
142
142
  :channel_data => 'a json string'
143
- }
143
+ })
144
144
  end
145
145
 
146
146
  it 'should fail on invalid socket_ids' do
147
- lambda {
147
+ expect {
148
148
  @channel.authenticate('1.1:')
149
- }.should raise_error Pusher::Error
149
+ }.to raise_error Pusher::Error
150
150
 
151
- lambda {
151
+ expect {
152
152
  @channel.authenticate('1.1foo', 'channel')
153
- }.should raise_error Pusher::Error
153
+ }.to raise_error Pusher::Error
154
154
 
155
- lambda {
155
+ expect {
156
156
  @channel.authenticate(':1.1')
157
- }.should raise_error Pusher::Error
157
+ }.to raise_error Pusher::Error
158
158
 
159
- lambda {
159
+ expect {
160
160
  @channel.authenticate('foo1.1', 'channel')
161
- }.should raise_error Pusher::Error
161
+ }.to raise_error Pusher::Error
162
162
 
163
- lambda {
163
+ expect {
164
164
  @channel.authenticate('foo', 'channel')
165
- }.should raise_error Pusher::Error
165
+ }.to raise_error Pusher::Error
166
166
  end
167
167
  end
168
168
  end
@@ -3,85 +3,6 @@ require 'spec_helper'
3
3
  require 'em-http'
4
4
 
5
5
  describe Pusher do
6
- describe 'using multiple Client objects' do
7
- before :each do
8
- @client1 = Pusher::Client.new
9
- @client2 = Pusher::Client.new
10
-
11
- @client1.scheme = 'ws'
12
- @client2.scheme = 'wss'
13
- @client1.host = 'one'
14
- @client2.host = 'two'
15
- @client1.port = 81
16
- @client2.port = 82
17
- @client1.app_id = '1111'
18
- @client2.app_id = '2222'
19
- @client1.key = 'AAAA'
20
- @client2.key = 'BBBB'
21
- @client1.secret = 'aaaaaaaa'
22
- @client2.secret = 'bbbbbbbb'
23
- end
24
-
25
- it "default should be configured automatically from environment variable" do
26
- Pusher.default_client.url.host.should == "api.secret.pusherapp.com"
27
- end
28
-
29
- it "should send scheme messages to different objects" do
30
- @client1.scheme.should_not == @client2.scheme
31
- end
32
-
33
- it "should send host messages to different objects" do
34
- @client1.host.should_not == @client2.host
35
- end
36
-
37
- it "should send port messages to different objects" do
38
- @client1.port.should_not == @client2.port
39
- end
40
-
41
- it "should send app_id messages to different objects" do
42
- @client1.app_id.should_not == @client2.app_id
43
- end
44
-
45
- it "should send app_id messages to different objects" do
46
- @client1.key.should_not == @client2.key
47
- end
48
-
49
- it "should send app_id messages to different objects" do
50
- @client1.secret.should_not == @client2.secret
51
- end
52
-
53
- it "should send app_id messages to different objects" do
54
- @client1.authentication_token.key.should_not == @client2.authentication_token.key
55
- @client1.authentication_token.secret.should_not == @client2.authentication_token.secret
56
- end
57
-
58
- it "should send url messages to different objects" do
59
- @client1.url.to_s.should_not == @client2.url.to_s
60
- @client1.url = 'ws://one/apps/111'
61
- @client2.url = 'wss://two/apps/222'
62
- @client1.scheme.should_not == @client2.scheme
63
- @client1.host.should_not == @client2.host
64
- @client1.app_id.should_not == @client2.app_id
65
- end
66
-
67
- it "should send encrypted messages to different objects" do
68
- @client1.encrypted = false
69
- @client2.encrypted = true
70
- @client1.scheme.should_not == @client2.scheme
71
- @client1.port.should_not == @client2.port
72
- end
73
-
74
- it "should send [] messages to different objects" do
75
- @client1['test'].should_not == @client2['test']
76
- end
77
-
78
- it "should send http_proxy messages to different objects" do
79
- @client1.http_proxy = 'http://oneuser:onepassword@onehost:8080'
80
- @client2.http_proxy = 'http://twouser:twopassword@twohost:8880'
81
- @client1.http_proxy.should_not == @client2.http_proxy
82
- end
83
- end
84
-
85
6
  # The behaviour should be the same when using the Client object, or the
86
7
  # 'global' client delegated through the Pusher class
87
8
  [lambda { Pusher }, lambda { Pusher::Client.new }].each do |client_gen|
@@ -91,23 +12,23 @@ describe Pusher do
91
12
 
92
13
  describe 'default configuration' do
93
14
  it 'should be preconfigured for api host' do
94
- @client.host.should == 'api.pusherapp.com'
15
+ expect(@client.host).to eq('api.pusherapp.com')
95
16
  end
96
17
 
97
18
  it 'should be preconfigured for port 80' do
98
- @client.port.should == 80
19
+ expect(@client.port).to eq(80)
99
20
  end
100
21
 
101
22
  it 'should use standard logger if no other logger if defined' do
102
23
  Pusher.logger.debug('foo')
103
- Pusher.logger.should be_kind_of(Logger)
24
+ expect(Pusher.logger).to be_kind_of(Logger)
104
25
  end
105
26
  end
106
27
 
107
28
  describe 'logging configuration' do
108
29
  it "can be configured to use any logger" do
109
30
  logger = double("ALogger")
110
- logger.should_receive(:debug).with('foo')
31
+ expect(logger).to receive(:debug).with('foo')
111
32
  Pusher.logger = logger
112
33
  Pusher.logger.debug('foo')
113
34
  Pusher.logger = nil
@@ -118,24 +39,24 @@ describe Pusher do
118
39
  it "should be possible to configure everything by setting the url" do
119
40
  @client.url = "test://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
120
41
 
121
- @client.scheme.should == 'test'
122
- @client.host.should == 'api.staging.pusherapp.com'
123
- @client.port.should == 8080
124
- @client.key.should == 'somekey'
125
- @client.secret.should == 'somesecret'
126
- @client.app_id.should == '87'
42
+ expect(@client.scheme).to eq('test')
43
+ expect(@client.host).to eq('api.staging.pusherapp.com')
44
+ expect(@client.port).to eq(8080)
45
+ expect(@client.key).to eq('somekey')
46
+ expect(@client.secret).to eq('somesecret')
47
+ expect(@client.app_id).to eq('87')
127
48
  end
128
49
 
129
50
  it "should override scheme and port when setting encrypted=true after url" do
130
51
  @client.url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
131
52
  @client.encrypted = true
132
53
 
133
- @client.scheme.should == 'https'
134
- @client.port.should == 443
54
+ expect(@client.scheme).to eq('https')
55
+ expect(@client.port).to eq(443)
135
56
  end
136
57
 
137
58
  it "should fail on bad urls" do
138
- expect { @client.url = "gopher/somekey:somesecret@://api.staging.pusherapp.co://m:8080\apps\87" }.to raise_error
59
+ expect { @client.url = "gopher/somekey:somesecret@://api.staging.pusherapp.co://m:8080\apps\87" }.to raise_error(URI::InvalidURIError)
139
60
  end
140
61
  end
141
62
 
@@ -143,7 +64,7 @@ describe Pusher do
143
64
  it "should be possible to configure everything by setting the http_proxy" do
144
65
  @client.http_proxy = 'http://someuser:somepassword@proxy.host.com:8080'
145
66
 
146
- @client.proxy.should == {:scheme => 'http', :host => 'proxy.host.com', :port => 8080, :user => 'someuser', :password => 'somepassword'}
67
+ expect(@client.proxy).to eq({:scheme => 'http', :host => 'proxy.host.com', :port => 8080, :user => 'someuser', :password => 'somepassword'})
147
68
  end
148
69
  end
149
70
 
@@ -160,15 +81,15 @@ describe Pusher do
160
81
  end
161
82
 
162
83
  it 'should return a channel' do
163
- @channel.should be_kind_of(Pusher::Channel)
84
+ expect(@channel).to be_kind_of(Pusher::Channel)
164
85
  end
165
86
 
166
87
  %w{app_id key secret}.each do |config|
167
88
  it "should raise exception if #{config} not configured" do
168
89
  @client.send("#{config}=", nil)
169
- lambda {
90
+ expect {
170
91
  @client['test_channel']
171
- }.should raise_error(Pusher::ConfigurationError)
92
+ }.to raise_error(Pusher::ConfigurationError)
172
93
  end
173
94
  end
174
95
  end
@@ -183,12 +104,12 @@ describe Pusher do
183
104
  "channel2" => {}
184
105
  })
185
106
  })
186
- @client.channels.should == {
107
+ expect(@client.channels).to eq({
187
108
  :channels => {
188
109
  "channel1" => {},
189
110
  "channel2" => {}
190
111
  }
191
- }
112
+ })
192
113
  end
193
114
  end
194
115
 
@@ -201,9 +122,9 @@ describe Pusher do
201
122
  'occupied' => false,
202
123
  })
203
124
  })
204
- @client.channel_info('mychannel').should == {
125
+ expect(@client.channel_info('mychannel')).to eq({
205
126
  :occupied => false,
206
- }
127
+ })
207
128
  end
208
129
  end
209
130
 
@@ -217,41 +138,41 @@ describe Pusher do
217
138
  end
218
139
 
219
140
  it "should call correct URL" do
220
- @client.trigger(['mychannel'], 'event', {'some' => 'data'}).
221
- should == {}
141
+ expect(@client.trigger(['mychannel'], 'event', {'some' => 'data'})).
142
+ to eq({})
222
143
  end
223
144
 
224
145
  it "should not allow too many channels" do
225
- lambda {
146
+ expect {
226
147
  @client.trigger((0..11).map{|i| 'mychannel#{i}'},
227
148
  'event', {'some' => 'data'}, {
228
149
  :socket_id => "12.34"
229
- })}.should raise_error(Pusher::Error)
150
+ })}.to raise_error(Pusher::Error)
230
151
  end
231
152
 
232
153
  it "should pass any parameters in the body of the request" do
233
154
  @client.trigger(['mychannel', 'c2'], 'event', {'some' => 'data'}, {
234
155
  :socket_id => "12.34"
235
156
  })
236
- WebMock.should have_requested(:post, @api_path).with { |req|
157
+ expect(WebMock).to have_requested(:post, @api_path).with { |req|
237
158
  parsed = MultiJson.decode(req.body)
238
- parsed["name"].should == 'event'
239
- parsed["channels"].should == ["mychannel", "c2"]
240
- parsed["socket_id"].should == '12.34'
159
+ expect(parsed["name"]).to eq('event')
160
+ expect(parsed["channels"]).to eq(["mychannel", "c2"])
161
+ expect(parsed["socket_id"]).to eq('12.34')
241
162
  }
242
163
  end
243
164
 
244
165
  it "should convert non string data to JSON before posting" do
245
166
  @client.trigger(['mychannel'], 'event', {'some' => 'data'})
246
- WebMock.should have_requested(:post, @api_path).with { |req|
247
- MultiJson.decode(req.body)["data"].should == '{"some":"data"}'
167
+ expect(WebMock).to have_requested(:post, @api_path).with { |req|
168
+ expect(MultiJson.decode(req.body)["data"]).to eq('{"some":"data"}')
248
169
  }
249
170
  end
250
171
 
251
172
  it "should accept a single channel as well as an array" do
252
173
  @client.trigger('mychannel', 'event', {'some' => 'data'})
253
- WebMock.should have_requested(:post, @api_path).with { |req|
254
- MultiJson.decode(req.body)["channels"].should == ['mychannel']
174
+ expect(WebMock).to have_requested(:post, @api_path).with { |req|
175
+ expect(MultiJson.decode(req.body)["channels"]).to eq(['mychannel'])
255
176
  }
256
177
  end
257
178
  end
@@ -268,7 +189,7 @@ describe Pusher do
268
189
  it "should call correct URL" do
269
190
  EM.run {
270
191
  @client.trigger_async('mychannel', 'event', {'some' => 'data'}).callback { |r|
271
- r.should == {}
192
+ expect(r).to eq({})
272
193
  EM.stop
273
194
  }
274
195
  }
@@ -279,8 +200,8 @@ describe Pusher do
279
200
  @client.trigger_async('mychannel', 'event', {'some' => 'data'}, {
280
201
  :socket_id => "12.34"
281
202
  }).callback {
282
- WebMock.should have_requested(:post, @api_path).with { |req|
283
- MultiJson.decode(req.body)["socket_id"].should == '12.34'
203
+ expect(WebMock).to have_requested(:post, @api_path).with { |req|
204
+ expect(MultiJson.decode(req.body)["socket_id"]).to eq('12.34')
284
205
  }
285
206
  EM.stop
286
207
  }
@@ -290,8 +211,8 @@ describe Pusher do
290
211
  it "should convert non string data to JSON before posting" do
291
212
  EM.run {
292
213
  @client.trigger_async('mychannel', 'event', {'some' => 'data'}).callback {
293
- WebMock.should have_requested(:post, @api_path).with { |req|
294
- MultiJson.decode(req.body)["data"].should == '{"some":"data"}'
214
+ expect(WebMock).to have_requested(:post, @api_path).with { |req|
215
+ expect(MultiJson.decode(req.body)["data"]).to eq('{"some":"data"}')
295
216
  }
296
217
  EM.stop
297
218
  }
@@ -311,13 +232,13 @@ describe Pusher do
311
232
 
312
233
  it "should use http by default" do
313
234
  call_api
314
- WebMock.should have_requested(verb, %r{http://api.pusherapp.com/apps/20/path})
235
+ expect(WebMock).to have_requested(verb, %r{http://api.pusherapp.com/apps/20/path})
315
236
  end
316
237
 
317
238
  it "should use https if configured" do
318
239
  @client.encrypted = true
319
240
  call_api
320
- WebMock.should have_requested(verb, %r{https://api.pusherapp.com})
241
+ expect(WebMock).to have_requested(verb, %r{https://api.pusherapp.com})
321
242
  end
322
243
 
323
244
  it "should format the respose hash with symbols at first level" do
@@ -325,9 +246,9 @@ describe Pusher do
325
246
  :status => 200,
326
247
  :body => MultiJson.encode({'something' => {'a' => 'hash'}})
327
248
  })
328
- call_api.should == {
249
+ expect(call_api).to eq({
329
250
  :something => {'a' => 'hash'}
330
- }
251
+ })
331
252
  end
332
253
 
333
254
  it "should catch all http exceptions and raise a Pusher::HTTPError wrapping the original error" do
@@ -340,35 +261,35 @@ describe Pusher do
340
261
  error = e
341
262
  end
342
263
 
343
- error.class.should == Pusher::HTTPError
344
- error.should be_kind_of(Pusher::Error)
345
- error.message.should == 'Exception from WebMock (HTTPClient::TimeoutError)'
346
- error.original_error.class.should == HTTPClient::TimeoutError
264
+ expect(error.class).to eq(Pusher::HTTPError)
265
+ expect(error).to be_kind_of(Pusher::Error)
266
+ expect(error.message).to eq('Exception from WebMock (HTTPClient::TimeoutError)')
267
+ expect(error.original_error.class).to eq(HTTPClient::TimeoutError)
347
268
  end
348
269
 
349
270
  it "should raise Pusher::Error if call returns 400" do
350
271
  stub_request(verb, @url_regexp).to_return({:status => 400})
351
- lambda { call_api }.should raise_error(Pusher::Error)
272
+ expect { call_api }.to raise_error(Pusher::Error)
352
273
  end
353
274
 
354
275
  it "should raise AuthenticationError if pusher returns 401" do
355
276
  stub_request(verb, @url_regexp).to_return({:status => 401})
356
- lambda { call_api }.should raise_error(Pusher::AuthenticationError)
277
+ expect { call_api }.to raise_error(Pusher::AuthenticationError)
357
278
  end
358
279
 
359
280
  it "should raise Pusher::Error if pusher returns 404" do
360
281
  stub_request(verb, @url_regexp).to_return({:status => 404})
361
- lambda { call_api }.should raise_error(Pusher::Error, '404 Not found (/apps/20/path)')
282
+ expect { call_api }.to raise_error(Pusher::Error, '404 Not found (/apps/20/path)')
362
283
  end
363
284
 
364
285
  it "should raise Pusher::Error if pusher returns 407" do
365
286
  stub_request(verb, @url_regexp).to_return({:status => 407})
366
- lambda { call_api }.should raise_error(Pusher::Error, 'Proxy Authentication Required')
287
+ expect { call_api }.to raise_error(Pusher::Error, 'Proxy Authentication Required')
367
288
  end
368
289
 
369
290
  it "should raise Pusher::Error if pusher returns 500" do
370
291
  stub_request(verb, @url_regexp).to_return({:status => 500, :body => "some error"})
371
- lambda { call_api }.should raise_error(Pusher::Error, 'Unknown error (status code 500): some error')
292
+ expect { call_api }.to raise_error(Pusher::Error, 'Unknown error (status code 500): some error')
372
293
  end
373
294
  end
374
295
  end
@@ -393,23 +314,23 @@ describe Pusher do
393
314
 
394
315
  it "should use http by default" do
395
316
  call_api
396
- WebMock.should have_requested(verb, %r{http://api.pusherapp.com/apps/20/path})
317
+ expect(WebMock).to have_requested(verb, %r{http://api.pusherapp.com/apps/20/path})
397
318
  end
398
319
 
399
320
  it "should use https if configured" do
400
321
  @client.encrypted = true
401
322
  call_api
402
- WebMock.should have_requested(verb, %r{https://api.pusherapp.com})
323
+ expect(WebMock).to have_requested(verb, %r{https://api.pusherapp.com})
403
324
  end
404
325
 
405
326
  # Note that the raw httpclient connection object is returned and
406
327
  # the response isn't handled (by handle_response) in the normal way.
407
328
  it "should return a httpclient connection object" do
408
329
  connection = call_api
409
- connection.finished?.should be_true
330
+ expect(connection.finished?).to be_truthy
410
331
  response = connection.pop
411
- response.status.should == 200
412
- response.body.read.should == "{}"
332
+ expect(response.status).to eq(200)
333
+ expect(response.body.read).to eq("{}")
413
334
  end
414
335
  end
415
336
  end
@@ -429,7 +350,7 @@ describe Pusher do
429
350
  it "should use http by default" do
430
351
  EM.run {
431
352
  call_api.callback {
432
- WebMock.should have_requested(verb, %r{http://api.pusherapp.com/apps/20/path})
353
+ expect(WebMock).to have_requested(verb, %r{http://api.pusherapp.com/apps/20/path})
433
354
  EM.stop
434
355
  }
435
356
  }
@@ -439,7 +360,7 @@ describe Pusher do
439
360
  EM.run {
440
361
  @client.encrypted = true
441
362
  call_api.callback {
442
- WebMock.should have_requested(verb, %r{https://api.pusherapp.com})
363
+ expect(WebMock).to have_requested(verb, %r{https://api.pusherapp.com})
443
364
  EM.stop
444
365
  }
445
366
  }
@@ -452,9 +373,9 @@ describe Pusher do
452
373
  :body => MultiJson.encode({'something' => {'a' => 'hash'}})
453
374
  })
454
375
  call_api.callback { |response|
455
- response.should == {
376
+ expect(response).to eq({
456
377
  :something => {'a' => 'hash'}
457
- }
378
+ })
458
379
  EM.stop
459
380
  }
460
381
  }
@@ -465,7 +386,7 @@ describe Pusher do
465
386
  stub_request(verb, @url_regexp).to_return({:status => 400})
466
387
 
467
388
  call_api.errback { |e|
468
- e.class.should == Pusher::Error
389
+ expect(e.class).to eq(Pusher::Error)
469
390
  EM.stop
470
391
  }.callback {
471
392
  fail
@@ -7,7 +7,6 @@ end
7
7
  ENV['PUSHER_URL']= 'http://some:secret@api.secret.pusherapp.com:441/apps/54'
8
8
 
9
9
  require 'rspec'
10
- require 'rspec/autorun'
11
10
  require 'em-http' # As of webmock 1.4.0, em-http must be loaded first
12
11
  require 'webmock/rspec'
13
12
 
@@ -22,9 +22,9 @@ describe Pusher::WebHook do
22
22
  'rack.input' => StringIO.new(MultiJson.encode(@hook_data))
23
23
  })
24
24
  wh = Pusher::WebHook.new(request)
25
- wh.key.should == '1234'
26
- wh.signature.should == 'asdf'
27
- wh.data.should == @hook_data
25
+ expect(wh.key).to eq('1234')
26
+ expect(wh.signature).to eq('asdf')
27
+ expect(wh.data).to eq(@hook_data)
28
28
  end
29
29
 
30
30
  it "can be initialized with a hash" do
@@ -35,9 +35,9 @@ describe Pusher::WebHook do
35
35
  :body => MultiJson.encode(@hook_data),
36
36
  }
37
37
  wh = Pusher::WebHook.new(request)
38
- wh.key.should == '1234'
39
- wh.signature.should == 'asdf'
40
- wh.data.should == @hook_data
38
+ expect(wh.key).to eq('1234')
39
+ expect(wh.signature).to eq('asdf')
40
+ expect(wh.data).to eq(@hook_data)
41
41
  end
42
42
  end
43
43
 
@@ -58,14 +58,14 @@ describe Pusher::WebHook do
58
58
  it "should validate" do
59
59
  @client.key = '1234'
60
60
  @client.secret = 'asdf'
61
- @wh.should be_valid
61
+ expect(@wh).to be_valid
62
62
  end
63
63
 
64
64
  it "should not validate if key is wrong" do
65
65
  @client.key = '12345'
66
66
  @client.secret = 'asdf'
67
- Pusher.logger.should_receive(:warn).with("Received webhook with unknown key: 1234")
68
- @wh.should_not be_valid
67
+ expect(Pusher.logger).to receive(:warn).with("Received webhook with unknown key: 1234")
68
+ expect(@wh).not_to be_valid
69
69
  end
70
70
 
71
71
  it "should not validate if secret is wrong" do
@@ -73,45 +73,45 @@ describe Pusher::WebHook do
73
73
  @client.secret = 'asdfxxx'
74
74
  digest = OpenSSL::Digest::SHA256.new
75
75
  expected = OpenSSL::HMAC.hexdigest(digest, @client.secret, @body)
76
- Pusher.logger.should_receive(:warn).with("Received WebHook with invalid signature: got #{@wh.signature}, expected #{expected}")
77
- @wh.should_not be_valid
76
+ expect(Pusher.logger).to receive(:warn).with("Received WebHook with invalid signature: got #{@wh.signature}, expected #{expected}")
77
+ expect(@wh).not_to be_valid
78
78
  end
79
79
 
80
80
  it "should validate with an extra token" do
81
81
  @client.key = '12345'
82
82
  @client.secret = 'xxx'
83
- @wh.valid?({:key => '1234', :secret => 'asdf'}).should be_true
83
+ expect(@wh.valid?({:key => '1234', :secret => 'asdf'})).to be_truthy
84
84
  end
85
85
 
86
86
  it "should validate with an array of extra tokens" do
87
87
  @client.key = '123456'
88
88
  @client.secret = 'xxx'
89
- @wh.valid?([
89
+ expect(@wh.valid?([
90
90
  {:key => '12345', :secret => 'wtf'},
91
91
  {:key => '1234', :secret => 'asdf'}
92
- ]).should be_true
92
+ ])).to be_truthy
93
93
  end
94
94
 
95
95
  it "should not validate if all keys are wrong with extra tokens" do
96
96
  @client.key = '123456'
97
97
  @client.secret = 'asdf'
98
- Pusher.logger.should_receive(:warn).with("Received webhook with unknown key: 1234")
99
- @wh.valid?({:key => '12345', :secret => 'asdf'}).should be_false
98
+ expect(Pusher.logger).to receive(:warn).with("Received webhook with unknown key: 1234")
99
+ expect(@wh.valid?({:key => '12345', :secret => 'asdf'})).to be_falsey
100
100
  end
101
101
 
102
102
  it "should not validate if secret is wrong with extra tokens" do
103
103
  @client.key = '123456'
104
104
  @client.secret = 'asdfxxx'
105
- Pusher.logger.should_receive(:warn).with(/Received WebHook with invalid signature/)
106
- @wh.valid?({:key => '1234', :secret => 'wtf'}).should be_false
105
+ expect(Pusher.logger).to receive(:warn).with(/Received WebHook with invalid signature/)
106
+ expect(@wh.valid?({:key => '1234', :secret => 'wtf'})).to be_falsey
107
107
  end
108
108
 
109
109
  it "should expose events" do
110
- @wh.events.should == @hook_data["events"]
110
+ expect(@wh.events).to eq(@hook_data["events"])
111
111
  end
112
112
 
113
113
  it "should expose time" do
114
- @wh.time.should == Time.at(123.456)
114
+ expect(@wh.time).to eq(Time.at(123.456))
115
115
  end
116
116
  end
117
117
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.5
4
+ version: 0.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pusher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: signature
28
+ name: pusher-signature
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  requirements: []
172
172
  rubyforge_project:
173
- rubygems_version: 2.4.6
173
+ rubygems_version: 2.4.8
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Pusher API client