Skip to content

Commit 967cd60

Browse files
committed
Set multiple path parameters and query_string with do_request for :get method
1 parent 352587e commit 967cd60

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rspec_api_documentation/dsl/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def do_request(extra_params = {})
3939
path_or_query = path
4040

4141
if method == :get && !query_string.blank?
42-
path_or_query = path + "?#{query_string}"
42+
path_or_query += "?#{query_string}"
4343
else
4444
params_or_body = respond_to?(:raw_post) ? raw_post : params
4545
end

spec/dsl_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@
181181
end
182182
end
183183

184+
get "/orders/:order_id/line_items/:id" do
185+
parameter :type, "The type document you want"
186+
187+
describe "do_request" do
188+
it "should correctly set path variables and other parameters" do
189+
client.should_receive(method).with("/orders/3/line_items/2?type=short", nil, nil)
190+
do_request(:id => 2, :order_id => 3, :type => 'short')
191+
end
192+
end
193+
end
194+
184195
get "/orders/:order_id" do
185196
let(:order) { stub(:id => 1) }
186197

0 commit comments

Comments
 (0)