Skip to content

Commit 5224387

Browse files
committed
Merge pull request #119 from NZN/fix_curl_generation
Fixing curl generation when nil header is passed
2 parents 2b0e4f7 + dfb621b commit 5224387

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/rspec_api_documentation/curl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def format_header(header)
6969
end
7070

7171
def format_full_header(header, value)
72-
formatted_value = value.gsub(/"/, "\\\"")
72+
formatted_value = value ? value.gsub(/"/, "\\\"") : ''
7373
"#{format_header(header)}: #{formatted_value}"
7474
end
7575

spec/curl_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"HTTP_X_HEADER" => "header",
1616
"HTTP_AUTHORIZATION" => %{Token token="mytoken"},
1717
"HTTP_HOST" => "example.org",
18-
"HTTP_COOKIES" => ""
18+
"HTTP_COOKIES" => "",
19+
"HTTP_SERVER" => nil
1920
}
2021
end
2122

@@ -26,6 +27,7 @@
2627
it { should =~ /-H "Accept: application\/json"/ }
2728
it { should =~ /-H "X-Header: header"/ }
2829
it { should =~ /-H "Authorization: Token token=\\"mytoken\\""/ }
30+
it { should =~ /-H "Server: "/ }
2931
it { should_not =~ /-H "Host: example\.org"/ }
3032
it { should_not =~ /-H "Cookies: "/ }
3133

0 commit comments

Comments
 (0)