pusher-fake 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v1.12.5
2
+ * Pusher JavaScript Library v1.12.7
3
3
  * http://pusherapp.com/
4
4
  *
5
5
  * Copyright 2011, Pusher
@@ -81,7 +81,7 @@
81
81
  },
82
82
 
83
83
  subscribeAll: function() {
84
- var channel;
84
+ var channelName;
85
85
  for (channelName in this.channels.channels) {
86
86
  if (this.channels.channels.hasOwnProperty(channelName)) {
87
87
  this.subscribe(channelName);
@@ -123,7 +123,8 @@
123
123
  },
124
124
 
125
125
  checkAppKey: function() {
126
- if(this.key === null || this.key === undefined) {
126
+ if (!this.key) {
127
+ // do not allow undefined, null or empty string
127
128
  Pusher.warn('Warning', 'You must pass your app key when you instantiate Pusher.');
128
129
  }
129
130
  }
@@ -183,7 +184,7 @@
183
184
  };
184
185
 
185
186
  // Pusher defaults
186
- Pusher.VERSION = '1.12.5';
187
+ Pusher.VERSION = '1.12.7';
187
188
  // WS connection parameters
188
189
  Pusher.host = 'ws.pusherapp.com';
189
190
  Pusher.ws_port = 80;
@@ -1019,22 +1020,26 @@ Example:
1019
1020
 
1020
1021
  var Members = function(channel) {
1021
1022
  var self = this;
1023
+ var channelData = null;
1022
1024
 
1023
1025
  var reset = function() {
1024
- this._members_map = {};
1025
- this.count = 0;
1026
- this.me = null;
1026
+ self._members_map = {};
1027
+ self.count = 0;
1028
+ self.me = null;
1029
+ channelData = null;
1030
+ };
1031
+ reset();
1032
+
1033
+ var subscriptionSucceeded = function(subscriptionData) {
1034
+ self._members_map = subscriptionData.presence.hash;
1035
+ self.count = subscriptionData.presence.count;
1036
+ self.me = self.get(channelData.user_id);
1037
+ channel.emit('pusher:subscription_succeeded', self);
1027
1038
  };
1028
- reset.call(this);
1029
1039
 
1030
1040
  channel.bind('pusher_internal:authorized', function(authorizedData) {
1031
- var channelData = JSON.parse(authorizedData.channel_data);
1032
- channel.bind("pusher_internal:subscription_succeeded", function(subscriptionData) {
1033
- self._members_map = subscriptionData.presence.hash;
1034
- self.count = subscriptionData.presence.count;
1035
- self.me = self.get(channelData.user_id);
1036
- channel.emit('pusher:subscription_succeeded', self);
1037
- });
1041
+ channelData = JSON.parse(authorizedData.channel_data);
1042
+ channel.bind("pusher_internal:subscription_succeeded", subscriptionSucceeded);
1038
1043
  });
1039
1044
 
1040
1045
  channel.bind('pusher_internal:member_added', function(data) {
@@ -1056,7 +1061,8 @@ Example:
1056
1061
  });
1057
1062
 
1058
1063
  channel.bind('pusher_internal:disconnected', function() {
1059
- reset.call(self);
1064
+ reset();
1065
+ channel.unbind("pusher_internal:subscription_succeeded", subscriptionSucceeded);
1060
1066
  });
1061
1067
  };
1062
1068
 
@@ -1091,6 +1097,7 @@ Example:
1091
1097
  return channel;
1092
1098
  };
1093
1099
  }).call(this);
1100
+
1094
1101
  ;(function() {
1095
1102
  Pusher.Channel.Authorizer = function(channel, type, options) {
1096
1103
  this.channel = channel;
@@ -1245,10 +1252,22 @@ var _require = (function() {
1245
1252
  deps.push(root + '/json2' + Pusher.dependency_suffix + '.js');
1246
1253
  }
1247
1254
  if (!window['WebSocket']) {
1248
- // Try to use web-socket-js (flash WebSocket emulation)
1249
- window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
1250
- window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;
1251
- deps.push(root + '/flashfallback' + Pusher.dependency_suffix + '.js');
1255
+ var flashSupported;
1256
+ try {
1257
+ flashSupported = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
1258
+ } catch (e) {
1259
+ flashSupported = navigator.mimeTypes["application/x-shockwave-flash"] !== undefined;
1260
+ }
1261
+
1262
+ if (flashSupported) {
1263
+ // Try to use web-socket-js (flash WebSocket emulation)
1264
+ window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
1265
+ window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;
1266
+ deps.push(root + '/flashfallback' + Pusher.dependency_suffix + '.js');
1267
+ } else {
1268
+ // Use SockJS when Flash is not available
1269
+ deps.push(root + '/sockjs' + Pusher.dependency_suffix + '.js');
1270
+ }
1252
1271
  }
1253
1272
 
1254
1273
  var initialize = function() {
@@ -1271,13 +1290,10 @@ var _require = (function() {
1271
1290
  })
1272
1291
  WebSocket.__initialize();
1273
1292
  } else {
1274
- // web-socket-js cannot initialize (most likely flash not installed)
1275
- sockjsPath = root + '/sockjs' + Pusher.dependency_suffix + '.js';
1276
- _require([sockjsPath], function() {
1277
- Pusher.Transport = SockJS;
1278
- Pusher.TransportType = 'sockjs';
1279
- Pusher.ready();
1280
- })
1293
+ // Flash fallback was not loaded, using SockJS
1294
+ Pusher.Transport = window.SockJS;
1295
+ Pusher.TransportType = 'sockjs';
1296
+ Pusher.ready();
1281
1297
  }
1282
1298
  }
1283
1299
  }
@@ -13,7 +13,7 @@
13
13
  <ul></ul>
14
14
  </section>
15
15
 
16
- <script src="/javascripts/vendor/pusher-1.12.5.js"></script>
16
+ <script src="/javascripts/vendor/pusher-1.12.7.js"></script>
17
17
  <script>
18
18
  window.addEventListener("DOMContentLoaded", function() {
19
19
  // Use the PusherFake server.
@@ -16,7 +16,7 @@ require "pusher-fake/webhook"
16
16
 
17
17
  module PusherFake
18
18
  # The current version string.
19
- VERSION = "0.6.0"
19
+ VERSION = "0.7.0"
20
20
 
21
21
  # Call this method to modify the defaults.
22
22
  #
@@ -24,6 +24,8 @@ module PusherFake
24
24
  channel($1, request)
25
25
  when %r{\A/apps/#{id}/channels/([^/]+)/users\Z}
26
26
  users($1)
27
+ else
28
+ unknown_path(request.path)
27
29
  end
28
30
 
29
31
  Rack::Response.new(MultiJson.dump(response)).finish
@@ -111,6 +113,15 @@ module PusherFake
111
113
 
112
114
  { users: users || [] }
113
115
  end
116
+
117
+ def self.unknown_path(path)
118
+ message = "Unknown path: #{path}"
119
+
120
+ logger = Logger.new(STDOUT)
121
+ logger.error(message)
122
+
123
+ raise message
124
+ end
114
125
  end
115
126
  end
116
127
  end
@@ -74,6 +74,49 @@ describe PusherFake::Server::Application, ".call, for retrieving occupied channe
74
74
  end
75
75
  end
76
76
 
77
+ describe PusherFake::Server::Application, ".call, with unknown path" do
78
+ let(:path) { "/apps/fake/events" }
79
+ let(:request) { stub(path: path) }
80
+ let(:message) { "Unknown path: #{path}" }
81
+ let(:response) { mock }
82
+ let(:environment) { mock }
83
+
84
+ before do
85
+ subject.stubs(:unknown_path).raises(message)
86
+
87
+ response.stubs(finish: response)
88
+
89
+ Rack::Request.stubs(new: request)
90
+ Rack::Response.stubs(new: response)
91
+ end
92
+
93
+ subject { PusherFake::Server::Application }
94
+
95
+ it "creates a request" do
96
+ subject.call(environment)
97
+ Rack::Request.should have_received(:new).with(environment)
98
+ end
99
+
100
+ it "calls unknown_path with the path" do
101
+ subject.call(environment)
102
+ subject.should have_received(:unknown_path).with(request.path)
103
+ end
104
+
105
+ it "creates a Rack response with the error message" do
106
+ subject.call(environment)
107
+ Rack::Response.should have_received(:new).with(message, 400)
108
+ end
109
+
110
+ it "finishes the response" do
111
+ subject.call(environment)
112
+ response.should have_received(:finish).with()
113
+ end
114
+
115
+ it "returns the response" do
116
+ subject.call(environment).should == response
117
+ end
118
+ end
119
+
77
120
  describe PusherFake::Server::Application, ".call, raising an error" do
78
121
  let(:id) { PusherFake.configuration.app_id }
79
122
  let(:path) { "/apps/#{id}/channels" }
@@ -229,9 +272,9 @@ describe PusherFake::Server::Application, ".channels, requesting a user count on
229
272
  subject { PusherFake::Server::Application }
230
273
 
231
274
  it "raises an error" do
232
- lambda {
275
+ expect {
233
276
  subject.channels(request)
234
- }.should raise_error(subject::CHANNEL_FILTER_ERROR)
277
+ }.to raise_error(subject::CHANNEL_FILTER_ERROR)
235
278
  end
236
279
  end
237
280
 
@@ -309,9 +352,9 @@ describe PusherFake::Server::Application, ".channel, requesting a user count on
309
352
  subject { PusherFake::Server::Application }
310
353
 
311
354
  it "raises an error" do
312
- lambda {
355
+ expect {
313
356
  subject.channel("public-1", request)
314
- }.should raise_error(subject::CHANNEL_USER_COUNT_ERROR)
357
+ }.to raise_error(subject::CHANNEL_USER_COUNT_ERROR)
315
358
  end
316
359
  end
317
360
 
@@ -365,3 +408,31 @@ describe PusherFake::Server::Application, ".users, for an unknown channel" do
365
408
  subject.users("fake").should == { users: [] }
366
409
  end
367
410
  end
411
+
412
+ describe PusherFake::Server::Application, ".unknown_path" do
413
+ let(:path) { "/apps/fake/events" }
414
+ let(:logger) { stub(error: true) }
415
+ let(:message) { "Unknown path: #{path}" }
416
+
417
+ before do
418
+ Logger.stubs(new: logger)
419
+ end
420
+
421
+ subject { PusherFake::Server::Application }
422
+
423
+ it "creates a logger" do
424
+ expect { subject.unknown_path(path) }.to raise_error
425
+ Logger.should have_received(:new).with(STDOUT)
426
+ end
427
+
428
+ it "logs the error message" do
429
+ expect { subject.unknown_path(path) }.to raise_error
430
+ logger.should have_received(:error).with(message)
431
+ end
432
+
433
+ it "raises an error" do
434
+ expect {
435
+ subject.unknown_path(path)
436
+ }.to raise_error(message)
437
+ end
438
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-fake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: em-http-request
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 1.5.0
69
+ version: 1.6.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 1.5.0
77
+ version: 1.6.1
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bourne
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - '='
84
84
  - !ruby/object:Gem::Version
85
- version: 1.3.0
85
+ version: 1.3.2
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - '='
92
92
  - !ruby/object:Gem::Version
93
- version: 1.3.0
93
+ version: 1.3.2
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: capybara-webkit
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 0.14.1
101
+ version: 0.14.2
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 0.14.1
109
+ version: 0.14.2
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: cucumber
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - '='
132
132
  - !ruby/object:Gem::Version
133
- version: 0.11.2
133
+ version: 0.11.3
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - '='
140
140
  - !ruby/object:Gem::Version
141
- version: 0.11.2
141
+ version: 0.11.3
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: rake
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +178,7 @@ dependencies:
178
178
  requirements:
179
179
  - - '='
180
180
  - !ruby/object:Gem::Version
181
- version: 2.12.0
181
+ version: 2.13.0
182
182
  type: :development
183
183
  prerelease: false
184
184
  version_requirements: !ruby/object:Gem::Requirement
@@ -186,7 +186,7 @@ dependencies:
186
186
  requirements:
187
187
  - - '='
188
188
  - !ruby/object:Gem::Version
189
- version: 2.12.0
189
+ version: 2.13.0
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: sinatra
192
192
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +194,7 @@ dependencies:
194
194
  requirements:
195
195
  - - '='
196
196
  - !ruby/object:Gem::Version
197
- version: 1.3.3
197
+ version: 1.3.5
198
198
  type: :development
199
199
  prerelease: false
200
200
  version_requirements: !ruby/object:Gem::Requirement
@@ -202,7 +202,7 @@ dependencies:
202
202
  requirements:
203
203
  - - '='
204
204
  - !ruby/object:Gem::Version
205
- version: 1.3.3
205
+ version: 1.3.5
206
206
  - !ruby/object:Gem::Dependency
207
207
  name: yard
208
208
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +210,7 @@ dependencies:
210
210
  requirements:
211
211
  - - '='
212
212
  - !ruby/object:Gem::Version
213
- version: 0.8.3
213
+ version: 0.8.5
214
214
  type: :development
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
@@ -218,7 +218,7 @@ dependencies:
218
218
  requirements:
219
219
  - - '='
220
220
  - !ruby/object:Gem::Version
221
- version: 0.8.3
221
+ version: 0.8.5
222
222
  description: A fake Pusher server for development and testing.
223
223
  email: hello@tristandunn.com
224
224
  executables: []
@@ -249,7 +249,7 @@ files:
249
249
  - features/step_definitions/navigation_steps.rb
250
250
  - features/step_definitions/presence_steps.rb
251
251
  - features/step_definitions/webhook_steps.rb
252
- - features/support/application/public/javascripts/vendor/pusher-1.12.5.js
252
+ - features/support/application/public/javascripts/vendor/pusher-1.12.7.js
253
253
  - features/support/application/views/index.erb
254
254
  - features/support/application.rb
255
255
  - features/support/environment.rb
@@ -284,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
284
284
  version: '0'
285
285
  segments:
286
286
  - 0
287
- hash: -92888459837878587
287
+ hash: -3011704484738286884
288
288
  required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  none: false
290
290
  requirements:
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  segments:
295
295
  - 0
296
- hash: -92888459837878587
296
+ hash: -3011704484738286884
297
297
  requirements: []
298
298
  rubyforge_project:
299
299
  rubygems_version: 1.8.23
@@ -314,7 +314,7 @@ test_files:
314
314
  - features/step_definitions/navigation_steps.rb
315
315
  - features/step_definitions/presence_steps.rb
316
316
  - features/step_definitions/webhook_steps.rb
317
- - features/support/application/public/javascripts/vendor/pusher-1.12.5.js
317
+ - features/support/application/public/javascripts/vendor/pusher-1.12.7.js
318
318
  - features/support/application/views/index.erb
319
319
  - features/support/application.rb
320
320
  - features/support/environment.rb