From b847bde0bb46111af4219bf3ce92ab7effbe83bb Mon Sep 17 00:00:00 2001 From: Alexander Logvinov <avl@logvinov.com> Date: Tue, 9 Mar 2021 20:57:27 +0800 Subject: [PATCH] Fix header formatting --- lib/rspec_api_documentation/curl.rb | 2 +- spec/curl_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rspec_api_documentation/curl.rb b/lib/rspec_api_documentation/curl.rb index 09eea076..2f0b9f79 100644 --- a/lib/rspec_api_documentation/curl.rb +++ b/lib/rspec_api_documentation/curl.rb @@ -65,7 +65,7 @@ def format_auth_header(value) end def format_header(header) - header.gsub(/^HTTP_/, '').titleize.split.join("-") + header.gsub(/^HTTP_/, '').split(/ |\_|\-/).map! { |part| part.tap(&:capitalize!) }.join('-') end def format_full_header(header, value) diff --git a/spec/curl_spec.rb b/spec/curl_spec.rb index 743602a7..45b17929 100644 --- a/spec/curl_spec.rb +++ b/spec/curl_spec.rb @@ -14,6 +14,7 @@ "HTTP_ACCEPT" => "application/json", "HTTP_X_HEADER" => "header", "HTTP_AUTHORIZATION" => %{Token token="mytoken"}, + "HTTP_DEVICE-ID" => "header", "HTTP_HOST" => "example.org", "HTTP_COOKIES" => "", "HTTP_SERVER" => nil @@ -26,6 +27,7 @@ it { should =~ /-X POST/ } it { should =~ /-H "Accept: application\/json"/ } it { should =~ /-H "X-Header: header"/ } + it { should =~ /-H "Device-Id: header"/ } it { should =~ /-H "Authorization: Token token=\\"mytoken\\""/ } it { should =~ /-H "Server: "/ } it { should_not =~ /-H "Host: example\.org"/ }