diff --git a/lib/pusher.rb b/lib/pusher.rb index 0c269ff..44fd670 100644 --- a/lib/pusher.rb +++ b/lib/pusher.rb @@ -34,6 +34,7 @@ class << self def_delegators :default_client, :authentication_token, :url, :cluster def_delegators :default_client, :encrypted=, :url=, :cluster= + def_delegators :default_client, :use_tls=, :url=, :cluster= def_delegators :default_client, :timeout=, :connect_timeout=, :send_timeout=, :receive_timeout=, :keep_alive_timeout= def_delegators :default_client, :get, :get_async, :post, :post_async diff --git a/lib/pusher/client.rb b/lib/pusher/client.rb index bb7960b..3b743da 100644 --- a/lib/pusher/client.rb +++ b/lib/pusher/client.rb @@ -122,6 +122,14 @@ def encrypted? @scheme == 'https' end + def use_tls=(boolean) + self.encrypted = boolean + end + + def use_tls? + self.encrypted? + end + def cluster=(cluster) cluster = DEFAULT_CLUSTER if cluster.nil? || cluster.empty? diff --git a/spec/client_spec.rb b/spec/client_spec.rb index f374d1f..924d14f 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -70,7 +70,6 @@ @client.url }.to raise_error(Pusher::ConfigurationError) end - end describe 'configuring the cluster' do @@ -156,6 +155,17 @@ expect(client.port).to eq(8000) end + describe '#use_tls=' do + it "should set the use_tls configuration option as alias of encrypted" do + @client.use_tls = true + expect(@client.use_tls?).to eq(true) + expect(@client.encrypted?).to eq(true) + + @client.use_tls = false + expect(@client.use_tls?).to eq(false) + expect(@client.encrypted?).to eq(false) + end + end end describe 'configuring a http proxy' do