Permalink
Browse files

eliminate Ruby warnings

This is a cherry-pick of 86925fd
  • Loading branch information...
1 parent 4e0b64f commit 4208a72762b0c60cba3487aaf9caae3eb0f50736 @mislav mislav committed Jan 19, 2012
@@ -18,7 +18,6 @@ def call(env)
if http.use_ssl = (url.scheme == 'https' && (ssl = env[:ssl]) && true)
http.verify_mode = ssl[:verify_mode] || begin
if ssl.fetch(:verify, true)
- OpenSSL::SSL::VERIFY_PEER
# Use the default cert store by default, i.e. system ca certs
store = OpenSSL::X509::Store.new
store.set_default_paths
@@ -33,7 +33,10 @@ def initialize(url = nil, options = {})
@ssl = options[:ssl] || {}
@parallel_manager = options[:parallel]
+ @path_prefix = @host = @port = @scheme = nil
self.url_prefix = url if url
+
+ @proxy = nil
proxy(options[:proxy])
@params.update options[:params] if options[:params]
@@ -19,7 +19,7 @@ def self.dependency(lib = nil)
end
def self.loaded?
- @load_error.nil?
+ !defined? @load_error or @load_error.nil?
end
def initialize(app = nil)
@@ -15,8 +15,6 @@ def call(env)
end
def match_content_type(env)
- type = request_type(env)
-
if process_request?(env)
env[:request_headers][CONTENT_TYPE] ||= self.class.mime_type
yield env[:body] unless env[:body].respond_to?(:to_str)
@@ -5,8 +5,8 @@ class Response
# Used for simple response middleware.
class Middleware < Faraday::Middleware
def call(env)
- @app.call(env).on_complete do |env|
- on_complete(env)
+ @app.call(env).on_complete do |environment|
+ on_complete(environment)
end
end
@@ -35,7 +35,7 @@ def parse(header_string)
return unless header_string && !header_string.empty?
header_string.split(/\r\n/).
tap { |a| a.shift if a.first.index('HTTP/') == 0 }. # drop the HTTP status line
- map { |h| h.split(/:\s+/, 2) }.reject { |(k, v)| k.nil? }. # split key and value, ignore blank lines
+ map { |h| h.split(/:\s+/, 2) }.reject { |p| p[0].nil? }. # split key and value, ignore blank lines
each { |key, value|
# join multiple values with a comma
if self[key] then self[key] << ', ' << value
@@ -29,8 +29,8 @@ class LiveTest < Faraday::TestCase
define_method "test_#{adapter}_GET_retrieves_the_response_headers" do
response = create_connection(adapter).get('hello_world')
- assert_match /text\/html/, response.headers['Content-Type'], 'original case fail'
- assert_match /text\/html/, response.headers['content-type'], 'lowercase fail'
+ assert_match(/text\/html/, response.headers['Content-Type'], 'original case fail')
+ assert_match(/text\/html/, response.headers['content-type'], 'lowercase fail')
end
# https://github.com/geemus/excon/issues/10
@@ -69,7 +69,7 @@ class LiveTest < Faraday::TestCase
end
define_method "test_#{adapter}_POST_retrieves_the_response_headers" do
- assert_match /text\/html/, create_connection(adapter).post('echo_name').headers['content-type']
+ assert_match(/text\/html/, create_connection(adapter).post('echo_name').headers['content-type'])
end
define_method "test_#{adapter}_POST_sends_files" do
@@ -103,7 +103,7 @@ class LiveTest < Faraday::TestCase
# https://github.com/dbalatero/typhoeus/issues/84
if ENV['FORCE'] || !%w[Faraday::Adapter::Patron Faraday::Adapter::Typhoeus].include?(adapter.to_s)
define_method "test_#{adapter}_PUT_retrieves_the_response_headers" do
- assert_match /text\/html/, create_connection(adapter).put('echo_name').headers['content-type']
+ assert_match(/text\/html/, create_connection(adapter).put('echo_name').headers['content-type'])
end
end
@@ -126,29 +126,29 @@ class LiveTest < Faraday::TestCase
resp = create_connection(adapter).head do |req|
req.url 'hello', 'name' => 'zack'
end
- assert_match /text\/html/, resp.headers['content-type']
+ assert_match(/text\/html/, resp.headers['content-type'])
end
define_method "test_#{adapter}_HEAD_retrieves_no_response_body" do
assert_equal '', create_connection(adapter).head('hello_world').body.to_s
end
define_method "test_#{adapter}_HEAD_retrieves_the_response_headers" do
- assert_match /text\/html/, create_connection(adapter).head('hello_world').headers['content-type']
+ assert_match(/text\/html/, create_connection(adapter).head('hello_world').headers['content-type'])
end
define_method "test_#{adapter}_DELETE_retrieves_the_response_headers" do
- assert_match /text\/html/, create_connection(adapter).delete('delete_with_json').headers['content-type']
+ assert_match(/text\/html/, create_connection(adapter).delete('delete_with_json').headers['content-type'])
end
define_method "test_#{adapter}_DELETE_retrieves_the_body" do
- assert_match /deleted/, create_connection(adapter).delete('delete_with_json').body
+ assert_match(/deleted/, create_connection(adapter).delete('delete_with_json').body)
end
define_method "test_#{adapter}_async_requests_clear_parallel_manager_after_running_a_single_request" do
connection = create_connection(adapter)
assert !connection.in_parallel?
- resp = connection.get('hello_world')
+ connection.get('hello_world')
assert !connection.in_parallel?
assert_equal 'hello world', connection.get('hello_world').body
end
@@ -2,7 +2,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require 'rack/utils'
-Faraday::CompositeReadIO.send :attr_reader, :ios
+Faraday::CompositeReadIO.class_eval { attr_reader :ios }
class RequestMiddlewareTest < Faraday::TestCase
def setup

0 comments on commit 4208a72

Please sign in to comment.