diff --git a/lib/rspec_api_documentation/curl.rb b/lib/rspec_api_documentation/curl.rb index 31a2b1d8..4e6bc174 100644 --- a/lib/rspec_api_documentation/curl.rb +++ b/lib/rspec_api_documentation/curl.rb @@ -69,7 +69,7 @@ def format_header(header) end def format_full_header(header, value) - formatted_value = value.gsub(/"/, "\\\"") + formatted_value = value ? value.gsub(/"/, "\\\"") : '' "#{format_header(header)}: #{formatted_value}" end diff --git a/spec/curl_spec.rb b/spec/curl_spec.rb index 275a60c1..180b79ec 100644 --- a/spec/curl_spec.rb +++ b/spec/curl_spec.rb @@ -15,7 +15,8 @@ "HTTP_X_HEADER" => "header", "HTTP_AUTHORIZATION" => %{Token token="mytoken"}, "HTTP_HOST" => "example.org", - "HTTP_COOKIES" => "" + "HTTP_COOKIES" => "", + "HTTP_SERVER" => nil } end @@ -26,6 +27,7 @@ it { should =~ /-H "Accept: application\/json"/ } it { should =~ /-H "X-Header: header"/ } it { should =~ /-H "Authorization: Token token=\\"mytoken\\""/ } + it { should =~ /-H "Server: "/ } it { should_not =~ /-H "Host: example\.org"/ } it { should_not =~ /-H "Cookies: "/ }