Skip to content

Commit

Permalink
Merge pull request #119 from NZN/fix_curl_generation
Browse files Browse the repository at this point in the history
Fixing curl generation when nil header is passed
  • Loading branch information
oestrich committed Mar 6, 2014
2 parents 2b0e4f7 + dfb621b commit 5224387
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit 5224387

Please sign in to comment.