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
4545 end
4646
4747 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
5254 end
5355 end
5456
Original file line number Diff line number Diff line change 11require 'spec_helper'
22require 'rspec_api_documentation/dsl'
33require 'net/http'
4+ require "rack/test"
45
56describe "Non-api documentation specs" do
67 it "should not be polluted by the rspec api dsl" do |example |
396397 do_request
397398 end
398399 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
399430 end
400431 end
401432
You can’t perform that action at this time.
0 commit comments