Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing curl generation when nil header is passed #119

Merged
merged 1 commit into from
Mar 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rspec_api_documentation/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion spec/curl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: "/ }

Expand Down