disabling coverage in inspect methods

This commit is contained in:
HoneyryderChuck 2019-12-22 12:25:18 +00:00
parent b39272381d
commit 8d2f0fd064
6 changed files with 48 additions and 3 deletions

View File

@ -130,6 +130,12 @@ module HTTPX
@headers.to_s
end
# :nocov:
def inspect
to_hash.inspect
end
# :nocov:
# this is internal API and doesn't abide to other public API
# guarantees, like downcasing strings.
# Please do not use this outside of core!

View File

@ -96,10 +96,12 @@ module HTTPX
end
# :nocov:
# :nocov:
def inspect
id = @io.closed? ? "closed" : @io.to_io.fileno
"#<SSL(fd: #{id}): #{@ip}:#{@port} state: #{@state}>"
end
# :nocov:
private

View File

@ -133,10 +133,12 @@ module HTTPX
@state == :idle || @state == :closed
end
# :nocov:
def inspect
id = @io.closed? ? "closed" : @io.fileno
"#<TCP(fd: #{id}): #{@ip}:#{@port} (state: #{@state})>"
end
# :nocov:
private

View File

@ -38,10 +38,17 @@ module HTTPX
end
def ==(other)
if other.is_a?(Parameters)
case other
when Parameters
@uri == other.uri &&
@username == other.username &&
@password == other.password
when URI::Generic, String
proxy_uri = @uri.dup
proxy_uri.user = @username
proxy_uri.password = @password
other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other)
proxy_uri == other_uri
else
super
end

View File

@ -125,9 +125,15 @@ module HTTPX
nil
end
# :nocov:
def inspect
"#<Request #{@verb.to_s.upcase} #{path} @headers=#{@headers.to_hash} @body=#{@body}>"
"#<HTTPX::Request:#{object_id} " \
"#{@verb.to_s.upcase} " \
"#{uri} " \
"@headers=#{@headers} " \
"@body=#{@body}>"
end
# :nocov:
class Body
class << self
@ -203,6 +209,14 @@ module HTTPX
def chunk!
@headers.add("transfer-encoding", "chunked")
end
# :nocov:
def inspect
"#<HTTPX::Request::Body:#{object_id} " \
"@state=#{@state} " \
"#{unbounded_body? ? "@stream" : "@bytesize=#{bytesize}"}>"
end
# :nocov:
end
def transition(nextstate)

View File

@ -52,9 +52,15 @@ module HTTPX
bodyless? || (@request.verb == :connect && @status == 200)
end
# :nocov:
def inspect
"#<Response:#{object_id} @status=#{@status} @headers=#{@headers}>"
"#<Response:#{object_id} "\
"HTTP/#{version} " \
"@status=#{@status} " \
"@headers=#{@headers} " \
"@body=#{@body}>"
end
# :nocov:
def raise_for_status
return if @status < 400
@ -165,6 +171,14 @@ module HTTPX
to_s == other.to_s
end
# :nocov:
def inspect
"#<HTTPX::Response::Body:#{object_id} " \
"@state=#{@state} " \
"@length=#{@length}>"
end
# :nocov:
private
def rewind