Skip to content

Commit

Permalink
Add deprecation warning and improve documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristandunn committed Oct 31, 2013
1 parent f374e72 commit 6104331
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
20 changes: 16 additions & 4 deletions lib/pusher-fake/configuration.rb
Expand Up @@ -9,9 +9,13 @@ class Configuration
# @return [String] The Pusher API token. (Defaults to +PUSHER_API_SECRET+.)
attr_accessor :secret

# Options for the socket server. See +EventMachine::WebSocket.start+ for options.
#
# @return [Hash] Options for the socket server.
attr_accessor :socket_options

# Options for the web server. See +Thin::Server+ for options.
#
# @return [Hash] Options for the web server.
attr_accessor :web_options

Expand All @@ -31,33 +35,41 @@ def initialize

# Set the host on which the socket server listens.
#
# @deprecated
# @deprecated Please use {#socket_options} +Hash+ instead.
# @param host String
def socket_host=(host)
warn "[DEPRECATION] `socket_host=` is deprecated. Please use `socket_options=` instead."

socket_options[:host] = host
end

# Set the port on which the socket server listens.
#
# @deprecated
# @deprecated Please use {#socket_options} +Hash+ instead.
# @param port Integer
def socket_port=(port)
warn "[DEPRECATION] `socket_port=` is deprecated. Please use `socket_options=` instead."

socket_options[:port] = port
end

# Set the host on which the web server listens.
#
# @deprecated
# @deprecated Please use {#web_options} +Hash+ instead.
# @param host String
def web_host=(host)
warn "[DEPRECATION] `web_host=` is deprecated. Please use `web_options=` instead."

web_options[:host] = host
end

# Set the port on which the web server listens.
#
# @deprecated
# @deprecated Please use {#web_options} +Hash+ instead.
# @param port Integer
def web_port=(port)
warn "[DEPRECATION] `web_port=` is deprecated. Please use `web_options=` instead."

web_options[:port] = port
end

Expand Down
20 changes: 16 additions & 4 deletions spec/lib/pusher-fake/configuration_spec.rb
Expand Up @@ -11,28 +11,40 @@

describe PusherFake::Configuration, "#socket_host=" do
it "sets socket options host value" do
subject.socket_host = "192.168.0.1"
silence_warnings do
subject.socket_host = "192.168.0.1"
end

subject.socket_options[:host].should == "192.168.0.1"
end
end

describe PusherFake::Configuration, "#socket_post=" do
it "sets socket options host value" do
subject.socket_port = 443
silence_warnings do
subject.socket_port = 443
end

subject.socket_options[:port].should == 443
end
end

describe PusherFake::Configuration, "#web_host=" do
it "sets web options host value" do
subject.web_host = "192.168.0.1"
silence_warnings do
subject.web_host = "192.168.0.1"
end

subject.web_options[:host].should == "192.168.0.1"
end
end

describe PusherFake::Configuration, "#web_post=" do
it "sets web options host value" do
subject.web_port = 443
silence_warnings do
subject.web_port = 443
end

subject.web_options[:port].should == 443
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/support/warnings.rb
@@ -0,0 +1,8 @@
module Kernel
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, nil
yield
ensure
$VERBOSE = old_verbose
end
end

0 comments on commit 6104331

Please sign in to comment.