File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed
lib/rspec_api_documentation/dsl/endpoint Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,12 @@ def path_params
45
45
end
46
46
47
47
def method_name
48
- @method_name ||= begin
49
- [ custom_method_name , scoped_key , key ] . find do |name |
50
- name && example_group . respond_to? ( name )
51
- end
48
+ if custom_method_name
49
+ custom_method_name if example_group . respond_to? ( custom_method_name )
50
+ elsif scoped_key && example_group . respond_to? ( scoped_key )
51
+ scoped_key
52
+ elsif key && example_group . respond_to? ( key )
53
+ key
52
54
end
53
55
end
54
56
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
require 'rspec_api_documentation/dsl'
3
3
require 'net/http'
4
+ require "rack/test"
4
5
5
6
describe "Non-api documentation specs" do
6
7
it "should not be polluted by the rspec api dsl" do |example |
396
397
do_request
397
398
end
398
399
end
400
+
401
+ context "with reserved name parameter" do
402
+ context "without custom method name" do
403
+ parameter :status , "Filter order by status"
404
+
405
+ example "does not work as expected" do
406
+ expect { do_request } . to raise_error Rack ::Test ::Error , /No response yet/
407
+ end
408
+ end
409
+
410
+ context "with custom method name" do
411
+ parameter :status , "Filter order by status" , method : :status_param
412
+
413
+ context "when parameter value is not specified" do
414
+ example "does not serialize param" do
415
+ expect ( client ) . to receive ( method ) . with ( "/orders" , anything , anything )
416
+ do_request
417
+ end
418
+ end
419
+
420
+ context "when parameter value is specified" do
421
+ let ( :status_param ) { "pending" }
422
+
423
+ example "serializes param" do
424
+ expect ( client ) . to receive ( method ) . with ( "/orders?status=pending" , anything , anything )
425
+ do_request
426
+ end
427
+ end
428
+ end
429
+ end
399
430
end
400
431
end
401
432
You can’t perform that action at this time.
0 commit comments