pusher-fake 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/step_definitions/api_steps.rb +11 -9
- data/features/step_definitions/channel_steps.rb +6 -3
- data/features/step_definitions/client_steps.rb +4 -2
- data/features/step_definitions/event_steps.rb +4 -2
- data/features/step_definitions/presence_steps.rb +2 -2
- data/features/step_definitions/webhook_steps.rb +1 -1
- data/features/support/environment.rb +6 -0
- data/features/support/webhooks.rb +1 -1
- data/lib/pusher-fake.rb +8 -2
- data/lib/pusher-fake/channel/presence.rb +4 -2
- data/lib/pusher-fake/channel/public.rb +3 -3
- data/lib/pusher-fake/configuration.rb +10 -2
- data/lib/pusher-fake/connection.rb +10 -9
- data/lib/pusher-fake/server/application.rb +1 -1
- data/lib/pusher-fake/webhook.rb +6 -3
- data/spec/lib/pusher-fake/channel/presence_spec.rb +84 -27
- data/spec/lib/pusher-fake/channel/private_spec.rb +37 -20
- data/spec/lib/pusher-fake/channel/public_spec.rb +29 -18
- data/spec/lib/pusher-fake/channel_spec.rb +43 -15
- data/spec/lib/pusher-fake/configuration_spec.rb +11 -3
- data/spec/lib/pusher-fake/connection_spec.rb +74 -20
- data/spec/lib/pusher-fake/server/application_spec.rb +72 -36
- data/spec/lib/pusher-fake/server_spec.rb +46 -23
- data/spec/lib/pusher-fake/webhook_spec.rb +7 -3
- data/spec/lib/pusher_fake_spec.rb +41 -10
- data/spec/spec_helper.rb +4 -2
- data/spec/support/have_configuration_option_matcher.rb +12 -39
- metadata +4 -18
@@ -26,35 +26,66 @@ describe PusherFake, ".configuration" do
|
|
26
26
|
|
27
27
|
it "initializes a configuration object" do
|
28
28
|
subject.configuration
|
29
|
-
|
29
|
+
|
30
|
+
expect(PusherFake::Configuration).to have_received(:new)
|
30
31
|
end
|
31
32
|
|
32
33
|
it "memoizes the configuration" do
|
33
|
-
subject.configuration
|
34
|
-
|
35
|
-
PusherFake::Configuration.
|
34
|
+
2.times { subject.configuration }
|
35
|
+
|
36
|
+
expect(PusherFake::Configuration).to have_received(:new).once
|
36
37
|
end
|
37
38
|
|
38
39
|
it "returns the configuration" do
|
39
|
-
subject.configuration.
|
40
|
+
expect(subject.configuration).to eq(configuration)
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
44
|
describe PusherFake, ".javascript" do
|
44
|
-
let(:options) { { custom: "option" } }
|
45
45
|
let(:configuration) { subject.configuration }
|
46
46
|
|
47
47
|
subject { PusherFake }
|
48
48
|
|
49
49
|
it "returns JavaScript setting the host and port to the configured options" do
|
50
|
-
arguments
|
50
|
+
arguments = [configuration.key, configuration.to_options].map(&:to_json).join(",")
|
51
|
+
javascript = subject.javascript
|
51
52
|
|
52
|
-
|
53
|
+
expect(javascript).to eq("new Pusher(#{arguments})")
|
53
54
|
end
|
54
55
|
|
55
56
|
it "supports passing custom options" do
|
56
|
-
|
57
|
+
options = { custom: "option" }
|
58
|
+
arguments = [configuration.key, configuration.to_options(options)].map(&:to_json).join(",")
|
59
|
+
javascript = subject.javascript(options)
|
60
|
+
|
61
|
+
expect(javascript).to eq("new Pusher(#{arguments})")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe PusherFake, ".log" do
|
66
|
+
let(:logger) { stub(:<< => "") }
|
67
|
+
let(:message) { "Hello world." }
|
68
|
+
let(:configuration) { subject.configuration }
|
69
|
+
|
70
|
+
subject { PusherFake }
|
71
|
+
|
72
|
+
before do
|
73
|
+
configuration.logger = logger
|
74
|
+
end
|
75
|
+
|
76
|
+
it "forwards message to logger when verbose" do
|
77
|
+
configuration.verbose = true
|
78
|
+
|
79
|
+
subject.log(message)
|
80
|
+
|
81
|
+
expect(logger).to have_received(:<<).with(message + "\n").once
|
82
|
+
end
|
83
|
+
|
84
|
+
it "does not forward message when not verbose" do
|
85
|
+
configuration.verbose = false
|
86
|
+
|
87
|
+
subject.log(message)
|
57
88
|
|
58
|
-
|
89
|
+
expect(logger).to have_received(:<<).never
|
59
90
|
end
|
60
91
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,8 @@ Dir[File.expand_path("../support/**/*.rb", __FILE__)].each do |file|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
|
-
config.mock_with
|
11
|
-
config.
|
10
|
+
config.mock_with :mocha
|
11
|
+
config.expect_with :rspec do |rspec|
|
12
|
+
rspec.syntax = :expect
|
13
|
+
end
|
12
14
|
end
|
@@ -1,44 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def matches?(configuration)
|
8
|
-
@configuration = configuration
|
9
|
-
@configuration.respond_to?(@option).should == true
|
10
|
-
|
11
|
-
if instance_variables.include?(:@default)
|
12
|
-
actual = @configuration.__send__(@option)
|
13
|
-
|
14
|
-
if @default.is_a?(Hash)
|
15
|
-
@default.each do |key, value|
|
16
|
-
actual[key].should == value
|
17
|
-
end
|
18
|
-
else
|
19
|
-
actual.should == @default
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
@configuration.__send__(:"#{@option}=", "value")
|
24
|
-
@configuration.__send__(@option).should == "value"
|
25
|
-
end
|
26
|
-
|
27
|
-
def with_default(default)
|
28
|
-
@default = default
|
29
|
-
|
30
|
-
self
|
31
|
-
end
|
1
|
+
RSpec::Matchers.define :have_configuration_option do |option|
|
2
|
+
match do |configuration|
|
3
|
+
configuration.respond_to?(option) &&
|
4
|
+
configuration.respond_to?("#{option}=") &&
|
5
|
+
(@default.nil? || configuration.public_send(option) == @default)
|
6
|
+
end
|
32
7
|
|
33
|
-
|
34
|
-
|
35
|
-
description << " configuration option #{@option.inspect}"
|
36
|
-
description << " with a default of #{@default.inspect}" if instance_variables.include?("@default")
|
37
|
-
description
|
38
|
-
end
|
8
|
+
chain :with_default do |default|
|
9
|
+
@default = default
|
39
10
|
end
|
40
11
|
|
41
|
-
|
42
|
-
|
12
|
+
failure_message_for_should do |configuration|
|
13
|
+
description = "expected configuration to have #{option.inspect} option"
|
14
|
+
description << " with a default of #{@default.inspect}" unless @default.nil?
|
15
|
+
description
|
43
16
|
end
|
44
17
|
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.
|
4
|
+
version: 0.14.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: 2014-
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|
@@ -100,20 +100,6 @@ dependencies:
|
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: 1.1.1
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: coveralls
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - '='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 0.7.0
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - '='
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 0.7.0
|
117
103
|
- !ruby/object:Gem::Dependency
|
118
104
|
name: cucumber
|
119
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,14 +148,14 @@ dependencies:
|
|
162
148
|
requirements:
|
163
149
|
- - '='
|
164
150
|
- !ruby/object:Gem::Version
|
165
|
-
version: 3.
|
151
|
+
version: 3.1.1
|
166
152
|
type: :development
|
167
153
|
prerelease: false
|
168
154
|
version_requirements: !ruby/object:Gem::Requirement
|
169
155
|
requirements:
|
170
156
|
- - '='
|
171
157
|
- !ruby/object:Gem::Version
|
172
|
-
version: 3.
|
158
|
+
version: 3.1.1
|
173
159
|
- !ruby/object:Gem::Dependency
|
174
160
|
name: rspec
|
175
161
|
requirement: !ruby/object:Gem::Requirement
|