pusher-fake 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ require "pusher-fake/webhook"
16
16
 
17
17
  module PusherFake
18
18
  # The current version string.
19
- VERSION = "0.5.0"
19
+ VERSION = "0.6.0"
20
20
 
21
21
  # Call this method to modify the defaults.
22
22
  #
@@ -32,6 +32,16 @@ module PusherFake
32
32
 
33
33
  # @return [Configuration] Current configuration.
34
34
  def self.configuration
35
- @@configuration ||= Configuration.new
35
+ @configuration ||= Configuration.new
36
+ end
37
+
38
+ # Convenience method for the JS to override the Pusher client host and port.
39
+ #
40
+ # @return [String] JavaScript overriding the Pusher client host and port.
41
+ def self.javascript
42
+ <<-EOS
43
+ Pusher.host = #{configuration.socket_host.to_json};
44
+ Pusher.ws_port = #{configuration.socket_port.to_json};
45
+ EOS
36
46
  end
37
47
  end
@@ -0,0 +1,20 @@
1
+ # Use the same API key and secret as the live version.
2
+ PusherFake.configure do |configuration|
3
+ configuration.app_id = Pusher.app_id
4
+ configuration.key = Pusher.key
5
+ configuration.secret = Pusher.secret
6
+ end
7
+
8
+ # Set the host and port to the fake web server.
9
+ Pusher.host = PusherFake.configuration.web_host
10
+ Pusher.port = PusherFake.configuration.web_port
11
+
12
+ # Start the fake web server.
13
+ fork { PusherFake::Server.start }.tap do |id|
14
+ at_exit { Process.kill("KILL", id) }
15
+ end
16
+
17
+ # Reset channels between scenarios.
18
+ After do
19
+ PusherFake::Channel.reset
20
+ end
@@ -0,0 +1,64 @@
1
+ require "spec_helper"
2
+
3
+ describe PusherFake, ".configure" do
4
+ let(:configuration) { mock }
5
+
6
+ subject { PusherFake }
7
+
8
+ before do
9
+ subject.stubs(configuration: configuration)
10
+ end
11
+
12
+ it "yields the configuration" do
13
+ expect { |block| subject.configure(&block) }.to yield_with_args(configuration)
14
+ end
15
+ end
16
+
17
+ describe PusherFake, ".configuration" do
18
+ let(:configuration) { mock }
19
+
20
+ subject { PusherFake }
21
+
22
+ before do
23
+ PusherFake::Configuration.stubs(new: configuration)
24
+ PusherFake.instance_variable_set("@configuration", nil)
25
+ end
26
+
27
+ after do
28
+ PusherFake.instance_variable_set("@configuration", nil)
29
+ end
30
+
31
+ it "initializes a configuration object" do
32
+ subject.configuration
33
+ PusherFake::Configuration.should have_received(:new)
34
+ end
35
+
36
+ it "memoizes the configuration" do
37
+ subject.configuration
38
+ subject.configuration
39
+ PusherFake::Configuration.should have_received(:new).once
40
+ end
41
+
42
+ it "returns the configuration" do
43
+ subject.configuration.should == configuration
44
+ end
45
+ end
46
+
47
+ describe PusherFake, ".javascript" do
48
+ let(:socket_host) { "127.0.0.1" }
49
+ let(:socket_port) { 1234 }
50
+ let(:configuration) { stub(socket_host: socket_host, socket_port: socket_port) }
51
+
52
+ subject { PusherFake }
53
+
54
+ before do
55
+ PusherFake.stubs(configuration: configuration)
56
+ end
57
+
58
+ it "returns JavaScript setting the host and port to the configured options" do
59
+ subject.javascript.should == <<-EOS
60
+ Pusher.host = #{socket_host.to_json};
61
+ Pusher.ws_port = #{socket_port.to_json};
62
+ EOS
63
+ end
64
+ 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.5.0
4
+ version: 0.6.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-21 00:00:00.000000000 Z
12
+ date: 2013-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: em-http-request
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - '='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.3.8
37
+ version: 0.4.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - '='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.3.8
45
+ version: 0.4.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: thin
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +231,7 @@ files:
231
231
  - lib/pusher-fake/channel.rb
232
232
  - lib/pusher-fake/configuration.rb
233
233
  - lib/pusher-fake/connection.rb
234
+ - lib/pusher-fake/cucumber.rb
234
235
  - lib/pusher-fake/server/application.rb
235
236
  - lib/pusher-fake/server.rb
236
237
  - lib/pusher-fake/webhook.rb
@@ -265,9 +266,10 @@ files:
265
266
  - spec/lib/pusher-fake/server/application_spec.rb
266
267
  - spec/lib/pusher-fake/server_spec.rb
267
268
  - spec/lib/pusher-fake/webhook_spec.rb
269
+ - spec/lib/pusher_fake_spec.rb
268
270
  - spec/spec_helper.rb
269
271
  - spec/support/have_configuration_option_matcher.rb
270
- homepage: http://github.com/tristandunn/pusher-fake
272
+ homepage: https://github.com/tristandunn/pusher-fake
271
273
  licenses:
272
274
  - MIT
273
275
  post_install_message:
@@ -282,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
284
  version: '0'
283
285
  segments:
284
286
  - 0
285
- hash: 399560288532115736
287
+ hash: -92888459837878587
286
288
  required_rubygems_version: !ruby/object:Gem::Requirement
287
289
  none: false
288
290
  requirements:
@@ -291,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
293
  version: '0'
292
294
  segments:
293
295
  - 0
294
- hash: 399560288532115736
296
+ hash: -92888459837878587
295
297
  requirements: []
296
298
  rubyforge_project:
297
299
  rubygems_version: 1.8.23
@@ -329,6 +331,7 @@ test_files:
329
331
  - spec/lib/pusher-fake/server/application_spec.rb
330
332
  - spec/lib/pusher-fake/server_spec.rb
331
333
  - spec/lib/pusher-fake/webhook_spec.rb
334
+ - spec/lib/pusher_fake_spec.rb
332
335
  - spec/spec_helper.rb
333
336
  - spec/support/have_configuration_option_matcher.rb
334
337
  has_rdoc: