pusher-fake 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,15 +13,11 @@
13
13
  <ul></ul>
14
14
  </section>
15
15
 
16
- <script src="/javascripts/vendor/pusher-2.0.5.js"></script>
16
+ <script src="/javascripts/vendor/pusher-2.1.2.js"></script>
17
17
  <script>
18
18
  window.addEventListener("DOMContentLoaded", function() {
19
- // Use the PusherFake server.
20
- Pusher.host = <%= MultiJson.dump(PusherFake.configuration.socket_host) %>;
21
- Pusher.ws_port = <%= MultiJson.dump(PusherFake.configuration.socket_port) %>;
22
-
23
- // Create the client instance.
24
- Pusher.instance = new Pusher(<%= MultiJson.dump(PusherFake.configuration.key) %>);
19
+ // Create the client instance using the PusherFake server.
20
+ Pusher.instance = <%= PusherFake.javascript %>;
25
21
  Pusher.instance.events = {};
26
22
 
27
23
  // Force the connection to go unavailable after a single attempt.
@@ -1,3 +1,5 @@
1
- require "coveralls"
1
+ if ENV["CI"]
2
+ require "coveralls"
2
3
 
3
- Coveralls.wear_merged!
4
+ Coveralls.wear_merged!
5
+ end
data/lib/pusher-fake.rb CHANGED
@@ -16,7 +16,7 @@ require "pusher-fake/webhook"
16
16
 
17
17
  module PusherFake
18
18
  # The current version string.
19
- VERSION = "0.9.0"
19
+ VERSION = "0.10.0"
20
20
 
21
21
  # Call this method to modify the defaults.
22
22
  #
@@ -37,11 +37,11 @@ module PusherFake
37
37
 
38
38
  # Convenience method for the JS to override the Pusher client host and port.
39
39
  #
40
+ # @param [Hash] options Custom options for Pusher client.
40
41
  # @return [String] JavaScript overriding the Pusher client host and port.
41
- def self.javascript
42
+ def self.javascript(options = {})
42
43
  <<-EOS
43
- Pusher.host = #{configuration.socket_host.to_json};
44
- Pusher.ws_port = #{configuration.socket_port.to_json};
44
+ new Pusher(#{configuration.key.to_json}, #{configuration.to_options(options).to_json})
45
45
  EOS
46
46
  end
47
47
  end
@@ -35,5 +35,15 @@ module PusherFake
35
35
  self.web_port = 8081
36
36
  self.webhooks = []
37
37
  end
38
+
39
+ # Convert the configuration to a hash sutiable for Pusher JS options.
40
+ #
41
+ # @param [Hash] options Custom options for Pusher client.
42
+ def to_options(options = {})
43
+ options.merge({
44
+ wsHost: socket_host,
45
+ wsPort: socket_port
46
+ })
47
+ end
38
48
  end
39
49
  end
@@ -10,3 +10,17 @@ describe PusherFake::Configuration do
10
10
  it { should have_configuration_option(:web_port).with_default(8081) }
11
11
  it { should have_configuration_option(:webhooks).with_default([]) }
12
12
  end
13
+
14
+ describe PusherFake::Configuration, "#to_options" do
15
+ it "includes the socket host as wsHost" do
16
+ subject.to_options.should include(wsHost: subject.socket_host)
17
+ end
18
+
19
+ it "includes the socket port as wsPort" do
20
+ subject.to_options.should include(wsPort: subject.socket_port)
21
+ end
22
+
23
+ it "supports passing custom options" do
24
+ subject.to_options(custom: "option").should include(custom: "option")
25
+ end
26
+ end
@@ -45,20 +45,20 @@ describe PusherFake, ".configuration" do
45
45
  end
46
46
 
47
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) }
48
+ let(:options) { { custom: "option" } }
49
+ let(:configuration) { subject.configuration }
51
50
 
52
51
  subject { PusherFake }
53
52
 
54
- before do
55
- PusherFake.stubs(configuration: configuration)
56
- end
57
-
58
53
  it "returns JavaScript setting the host and port to the configured options" do
59
54
  subject.javascript.should == <<-EOS
60
- Pusher.host = #{socket_host.to_json};
61
- Pusher.ws_port = #{socket_port.to_json};
55
+ new Pusher(#{configuration.key.to_json}, #{configuration.to_options.to_json})
56
+ EOS
57
+ end
58
+
59
+ it "supports passing custom options" do
60
+ subject.javascript(options).should == <<-EOS
61
+ new Pusher(#{configuration.key.to_json}, #{configuration.to_options(options).to_json})
62
62
  EOS
63
63
  end
64
64
  end
@@ -1,3 +1,5 @@
1
- require "coveralls"
1
+ if ENV["CI"]
2
+ require "coveralls"
2
3
 
3
- Coveralls.wear_merged!
4
+ Coveralls.wear_merged!
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-fake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Dunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-11 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: em-websocket
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 1.4.0
75
+ version: 1.5.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 1.4.0
82
+ version: 1.5.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: capybara-webkit
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,70 +114,70 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.3.2
117
+ version: 1.3.6
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 1.3.2
124
+ version: 1.3.6
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pusher
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 0.11.3
131
+ version: 0.12.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 0.11.3
138
+ version: 0.12.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 10.0.4
145
+ version: 10.1.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 10.0.4
152
+ version: 10.1.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: redcarpet
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - '='
158
158
  - !ruby/object:Gem::Version
159
- version: 2.3.0
159
+ version: 3.0.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
- version: 2.3.0
166
+ version: 3.0.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 2.13.0
173
+ version: 2.14.1
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 2.13.0
180
+ version: 2.14.1
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: sinatra
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - '='
200
200
  - !ruby/object:Gem::Version
201
- version: 0.8.6.1
201
+ version: 0.8.7
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
- version: 0.8.6.1
208
+ version: 0.8.7
209
209
  description: A fake Pusher server for development and testing.
210
210
  email: hello@tristandunn.com
211
211
  executables: []
@@ -236,7 +236,7 @@ files:
236
236
  - features/step_definitions/navigation_steps.rb
237
237
  - features/step_definitions/presence_steps.rb
238
238
  - features/step_definitions/webhook_steps.rb
239
- - features/support/application/public/javascripts/vendor/pusher-2.0.5.js
239
+ - features/support/application/public/javascripts/vendor/pusher-2.1.2.js
240
240
  - features/support/application/views/index.erb
241
241
  - features/support/application.rb
242
242
  - features/support/coveralls.rb
@@ -296,7 +296,7 @@ test_files:
296
296
  - features/step_definitions/navigation_steps.rb
297
297
  - features/step_definitions/presence_steps.rb
298
298
  - features/step_definitions/webhook_steps.rb
299
- - features/support/application/public/javascripts/vendor/pusher-2.0.5.js
299
+ - features/support/application/public/javascripts/vendor/pusher-2.1.2.js
300
300
  - features/support/application/views/index.erb
301
301
  - features/support/application.rb
302
302
  - features/support/coveralls.rb