From 4b15530b5bfb0d8389c938d07f6a15e3c928e0ec Mon Sep 17 00:00:00 2001 From: Anton Prokhorov Date: Fri, 13 Feb 2015 12:13:24 +0300 Subject: [PATCH] headers ending in "id" are displayed correctly --- lib/rspec_api_documentation/headers.rb | 1 + spec/http_test_client_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rspec_api_documentation/headers.rb b/lib/rspec_api_documentation/headers.rb index 01b3e221..70f9acb8 100644 --- a/lib/rspec_api_documentation/headers.rb +++ b/lib/rspec_api_documentation/headers.rb @@ -8,6 +8,7 @@ def env_to_headers(env) # HTTP_ACCEPT_CHARSET => Accept-Charset if key =~ /^(HTTP_|CONTENT_TYPE)/ header = key.gsub(/^HTTP_/, '').titleize.split.join("-") + header.concat('-Id') if key.scan(/_ID\Z/).any? headers[header] = value end end diff --git a/spec/http_test_client_spec.rb b/spec/http_test_client_spec.rb index f3e48f8d..dc9305d2 100644 --- a/spec/http_test_client_spec.rb +++ b/spec/http_test_client_spec.rb @@ -62,13 +62,14 @@ describe "#request_headers" do before do - test_client.get "/", {}, { "Accept" => "application/json", "Content-Type" => "application/json" } + test_client.get "/", {}, { "Accept" => "application/json", "Content-Type" => "application/json", "User-Id" => "1" } end it "should contain all the headers" do expect(test_client.request_headers).to eq({ "Accept" => "application/json", - "Content-Type" => "application/json" + "Content-Type" => "application/json", + "User-Id" => "1" }) end end