Skip to content

Commit a344af8

Browse files
committed
Merge pull request #62 from mikz/master
Allow parameters without values
2 parents 3a2921b + 268f787 commit a344af8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/rspec_api_documentation/client_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def query_hash
7070
strings = query_string.split("&")
7171
arrays = strings.map do |segment|
7272
k,v = segment.split("=")
73-
[k, CGI.unescape(v)]
73+
[k, v && CGI.unescape(v)]
7474
end
7575
Hash[arrays]
7676
end

spec/rack_test_client_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ class StubApp < Sinatra::Base
8080
end
8181
end
8282

83+
context "when doing request without parameter value" do
84+
before do
85+
test_client.post "/greet?query=&other=exists"
86+
end
87+
88+
context "when examples should be documented", :document => true do
89+
it "should still argument the metadata" do
90+
metadata = example.metadata[:requests].first
91+
metadata[:request_query_parameters].should == {'query' => nil, 'other' => 'exists'}
92+
end
93+
end
94+
end
95+
8396
context "after a request is made" do
8497
before do
8598
test_client.post "/greet?query=test+query", post_data, headers

0 commit comments

Comments
 (0)