Skip to content

Commit

Permalink
Merge pull request #62 from mikz/master
Browse files Browse the repository at this point in the history
Allow parameters without values
  • Loading branch information
oestrich committed Mar 28, 2013
2 parents 3a2921b + 268f787 commit a344af8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec_api_documentation/client_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def query_hash
strings = query_string.split("&")
arrays = strings.map do |segment|
k,v = segment.split("=")
[k, CGI.unescape(v)]
[k, v && CGI.unescape(v)]
end
Hash[arrays]
end
Expand Down
13 changes: 13 additions & 0 deletions spec/rack_test_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ class StubApp < Sinatra::Base
end
end

context "when doing request without parameter value" do
before do
test_client.post "/greet?query=&other=exists"
end

context "when examples should be documented", :document => true do
it "should still argument the metadata" do
metadata = example.metadata[:requests].first
metadata[:request_query_parameters].should == {'query' => nil, 'other' => 'exists'}
end
end
end

context "after a request is made" do
before do
test_client.post "/greet?query=test+query", post_data, headers
Expand Down

0 comments on commit a344af8

Please sign in to comment.