Skip to content

Commit 91eb365

Browse files
authored
fix: Simplify response and headers inspection (#810)
* Dumping all headers in `Headers#inspect` mostly useless * Same about response, the only header part that is meaningfull there is MIME type More importantly, Ruby-3.4 changed the inspect output, and we will either need to have if/else in specs, or modify the output to become ruby version-agnostic (i.e., not using Hash#inspect). Blocks: #808
1 parent 954225f commit 91eb365

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/http/headers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def to_a
147147
#
148148
# @return [String]
149149
def inspect
150-
"#<#{self.class} #{to_h.inspect}>"
150+
"#<#{self.class}>"
151151
end
152152

153153
# Returns list of header names.

lib/http/response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def parse(type = nil)
162162

163163
# Inspect a response
164164
def inspect
165-
"#<#{self.class}/#{@version} #{code} #{reason} #{headers.to_h.inspect}>"
165+
"#<#{self.class}/#{@version} #{code} #{reason} #{mime_type}>"
166166
end
167167

168168
private

spec/lib/http/headers_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282

283283
before { headers.set :set_cookie, %w[hoo=ray woo=hoo] }
284284

285-
it { is_expected.to eq '#<HTTP::Headers {"Set-Cookie"=>["hoo=ray", "woo=hoo"]}>' }
285+
it { is_expected.to eq "#<HTTP::Headers>" }
286286
end
287287

288288
describe "#keys" do

spec/lib/http/response_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
let(:headers) { {content_type: "text/plain"} }
156156
let(:body) { double to_s: "foobar" }
157157

158-
it { is_expected.to eq '#<HTTP::Response/1.1 200 OK {"Content-Type"=>"text/plain"}>' }
158+
it { is_expected.to eq "#<HTTP::Response/1.1 200 OK text/plain>" }
159159
end
160160

161161
describe "#cookies" do

0 commit comments

Comments
 (0)