From e5ebd7704b4d6f641f7a268eb6b4038f04b4b053 Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Sat, 21 Jun 2025 22:43:26 +0200 Subject: [PATCH] fix: Simplify response and headers inspection * 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: https://github.com/httprb/http/pull/808 --- lib/http/headers.rb | 2 +- lib/http/response.rb | 2 +- spec/lib/http/headers_spec.rb | 2 +- spec/lib/http/response_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/http/headers.rb b/lib/http/headers.rb index 5f285616..9898e220 100644 --- a/lib/http/headers.rb +++ b/lib/http/headers.rb @@ -147,7 +147,7 @@ def to_a # # @return [String] def inspect - "#<#{self.class} #{to_h.inspect}>" + "#<#{self.class}>" end # Returns list of header names. diff --git a/lib/http/response.rb b/lib/http/response.rb index 6212b5a6..5ac74c86 100644 --- a/lib/http/response.rb +++ b/lib/http/response.rb @@ -162,7 +162,7 @@ def parse(type = nil) # Inspect a response def inspect - "#<#{self.class}/#{@version} #{code} #{reason} #{headers.to_h.inspect}>" + "#<#{self.class}/#{@version} #{code} #{reason} #{mime_type}>" end private diff --git a/spec/lib/http/headers_spec.rb b/spec/lib/http/headers_spec.rb index e4ac774d..e5ae4210 100644 --- a/spec/lib/http/headers_spec.rb +++ b/spec/lib/http/headers_spec.rb @@ -282,7 +282,7 @@ before { headers.set :set_cookie, %w[hoo=ray woo=hoo] } - it { is_expected.to eq '#["hoo=ray", "woo=hoo"]}>' } + it { is_expected.to eq "#" } end describe "#keys" do diff --git a/spec/lib/http/response_spec.rb b/spec/lib/http/response_spec.rb index fc4bbd7e..3ce24881 100644 --- a/spec/lib/http/response_spec.rb +++ b/spec/lib/http/response_spec.rb @@ -155,7 +155,7 @@ let(:headers) { {content_type: "text/plain"} } let(:body) { double to_s: "foobar" } - it { is_expected.to eq '#"text/plain"}>' } + it { is_expected.to eq "#" } end describe "#cookies" do