Skip to content

Commit

Permalink
eliminate Ruby warnings
Browse files Browse the repository at this point in the history
This is a cherry-pick of 86925fd
  • Loading branch information
mislav committed Jan 21, 2012
1 parent 4e0b64f commit 4208a72
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
1 change: 0 additions & 1 deletion lib/faraday/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/faraday/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions lib/faraday/request/url_encoded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions test/adapters/live_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/request_middleware_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4208a72

Please sign in to comment.