mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
moar coverage
This commit is contained in:
parent
0fe4040da0
commit
96eaf1ef05
@ -62,7 +62,6 @@ module HTTPX
|
||||
:w
|
||||
end
|
||||
|
||||
# :nocov:
|
||||
if RUBY_VERSION < "2.2"
|
||||
# rubocop: disable Lint/UriEscapeUnescape:
|
||||
def initialize_with_escape(verb, uri, options = {})
|
||||
@ -72,7 +71,6 @@ module HTTPX
|
||||
alias_method :initialize, :initialize_with_escape
|
||||
# rubocop: enable Lint/UriEscapeUnescape:
|
||||
end
|
||||
# :nocov:
|
||||
|
||||
def merge_headers(h)
|
||||
@headers = @headers.merge(h)
|
||||
@ -178,19 +176,13 @@ module HTTPX
|
||||
return true if @body.nil?
|
||||
return false if chunked?
|
||||
|
||||
bytesize.zero?
|
||||
@body.bytesize.zero?
|
||||
end
|
||||
|
||||
def bytesize
|
||||
return 0 if @body.nil?
|
||||
|
||||
if @body.respond_to?(:bytesize)
|
||||
@body.bytesize
|
||||
elsif @body.respond_to?(:size)
|
||||
@body.size
|
||||
else
|
||||
raise Error, "cannot determine size of body: #{@body.inspect}"
|
||||
end
|
||||
@body.bytesize
|
||||
end
|
||||
|
||||
def stream(body)
|
||||
|
@ -5,6 +5,24 @@ require_relative "test_helper"
|
||||
class HeadersTest < Minitest::Test
|
||||
include HTTPX
|
||||
|
||||
def test_headers_clone
|
||||
h1 = Headers.new
|
||||
h2 = h1.clone
|
||||
h2.instance_variables.each do |ivar|
|
||||
assert !h1.instance_variable_get(ivar).nil?
|
||||
assert !h1.instance_variable_get(ivar).equal?(h2.instance_variable_get(ivar))
|
||||
end
|
||||
end
|
||||
|
||||
def test_headers_dup
|
||||
h1 = Headers.new
|
||||
h2 = h1.dup
|
||||
h2.instance_variables.each do |ivar|
|
||||
assert !h1.instance_variable_get(ivar).nil?
|
||||
assert !h1.instance_variable_get(ivar).equal?(h2.instance_variable_get(ivar))
|
||||
end
|
||||
end
|
||||
|
||||
def test_headers_set
|
||||
h1 = Headers.new
|
||||
assert h1["accept"].nil?, "unexpected header value"
|
||||
|
Loading…
x
Reference in New Issue
Block a user