File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
lib/rspec_api_documentation/dsl/endpoint Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,17 @@ module RspecApiDocumentation
2
2
module DSL
3
3
module Endpoint
4
4
class SetParam
5
+ RESERVED_WORDS = %w( status )
6
+
5
7
def initialize ( parent , hash , param )
6
8
@parent = parent
7
9
@hash = hash
8
10
@param = param
11
+
12
+ if reserved_word? ( key ) && !custom_method_name
13
+ raise ArgumentError , "Parameter name '#{ key } ' is reserved. " \
14
+ "Please provide `method` argument with custom method name."
15
+ end
9
16
end
10
17
11
18
def call
@@ -46,12 +53,16 @@ def path_params
46
53
47
54
def method_name
48
55
@method_name ||= begin
49
- [ custom_method_name , scoped_key , key ] . find do |name |
50
- name && example_group . respond_to ?( name )
56
+ [ custom_method_name , scoped_key , key ] . compact . find do |name |
57
+ example_group . respond_to? ( name ) && ! reserved_word ?( name )
51
58
end
52
59
end
53
60
end
54
61
62
+ def reserved_word? ( word )
63
+ RESERVED_WORDS . include? ( word . to_s )
64
+ end
65
+
55
66
def build_param_hash ( keys )
56
67
value = keys [ 1 ] ? build_param_hash ( keys [ 1 ..-1 ] ) : example_group . send ( method_name )
57
68
{ keys [ 0 ] . to_s => value }
You can’t perform that action at this time.
0 commit comments