Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add statistics configuration and disable by default.
  • Loading branch information
tristandunn committed Nov 1, 2018
1 parent 282e71f commit 7800b5b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Expand Up @@ -2,6 +2,7 @@

## 1.11.0 — Unreleased

* Add statistics configuration and disable by default. (Tristan Dunn)
* Update development and test dependencies. (Tristan Dunn)

## 1.10.0 — September 5, 2018
Expand Down
11 changes: 8 additions & 3 deletions lib/pusher-fake/configuration.rb
Expand Up @@ -4,6 +4,9 @@ class Configuration
# @return [String] The Pusher Applicaiton ID. (Defaults to +PUSHER_APP_ID+.)
attr_reader :app_id

# @return [Boolean] Disable the client statistics. (Defaults to +true+.)
attr_accessor :disable_stats

# @return [String] The Pusher API key. (Defaults to +PUSHER_API_KEY+.)
attr_accessor :key

Expand Down Expand Up @@ -49,6 +52,7 @@ def reset!
self.verbose = false
self.webhooks = []

self.disable_stats = true
self.socket_options = { host: "127.0.0.1", port: available_port }
self.web_options = { host: "127.0.0.1", port: available_port }
end
Expand All @@ -58,9 +62,10 @@ def reset!
# @param [Hash] options Custom options for Pusher client.
def to_options(options = {})
options.merge(
wsHost: socket_options[:host],
wsPort: socket_options[:port],
cluster: "us-east-1"
wsHost: socket_options[:host],
wsPort: socket_options[:port],
cluster: "us-east-1",
disableStats: disable_stats
)
end

Expand Down
11 changes: 11 additions & 0 deletions spec/lib/pusher-fake/configuration_spec.rb
@@ -1,6 +1,11 @@
require "spec_helper"

describe PusherFake::Configuration do
it do
expect(subject).to have_configuration_option(:disable_stats)
.with_default(true)
end

it do
expect(subject).to have_configuration_option(:key)
.with_default("PUSHER_API_KEY")
Expand Down Expand Up @@ -59,6 +64,12 @@
end

describe PusherFake::Configuration, "#to_options" do
it "includes disable_stats as disableStats" do
options = subject.to_options

expect(options).to include(disableStats: subject.disable_stats)
end

it "includes the socket host as wsHost" do
options = subject.to_options

Expand Down

0 comments on commit 7800b5b

Please sign in to comment.