diff --git a/lib/opensrs/server.rb b/lib/opensrs/server.rb index bb8701b..734297f 100644 --- a/lib/opensrs/server.rb +++ b/lib/opensrs/server.rb @@ -75,13 +75,13 @@ def signature(request) end def http - if @proxy - http = Net::HTTP.new(server.host, server.port, @proxy.host, @proxy.port, @proxy.user, @proxy.password) - else - http = Net::HTTP.new(server.host, server.port) - end + http = if @proxy + Net::HTTP.new(server.host, server.port, @proxy.host, @proxy.port, @proxy.user, @proxy.password) + else + Net::HTTP.new(server.host, server.port) + end - http.use_ssl = (server.scheme == "https") + http.use_ssl = (server.scheme == 'https') http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.read_timeout = http.open_timeout = @timeout if @timeout http.open_timeout = @open_timeout if @open_timeout diff --git a/spec/opensrs/server_spec.rb b/spec/opensrs/server_spec.rb index 0758c0c..9f1ffd2 100644 --- a/spec/opensrs/server_spec.rb +++ b/spec/opensrs/server_spec.rb @@ -33,8 +33,8 @@ end it 'allows a proxy to be set during initialization' do - proxy = "http://user:password@example.com:1234" - server = OpenSRS::Server.new({ :proxy => proxy }) + proxy = 'http://user:password@example.com:1234' + server = described_class.new({ proxy: proxy }) expect(server.proxy).to be_a(URI) end @@ -116,12 +116,12 @@ end it 'allows setting a proxy' do - proxy = URI("http://user:password@example.com:1234") + proxy = URI('http://user:password@example.com:1234') server.proxy = proxy Net::HTTP.should_receive(:new).with(anything, anything, proxy.host, proxy.port, proxy.user, proxy.password) - server.call( { :some => 'data' } ) + server.call({ some: 'data' }) end it 're-raises Net:HTTP timeouts' do