File tree 2 files changed +26
-1
lines changed
lib/rspec_api_documentation
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ def callback_url
96
96
97
97
def do_request ( extra_params = { } )
98
98
@extra_params = extra_params
99
+
99
100
params_or_body = nil
100
101
path_or_query = path
101
102
@@ -139,7 +140,9 @@ def path_params
139
140
140
141
def path
141
142
example . metadata [ :path ] . gsub ( /:(\w +)/ ) do |match |
142
- if respond_to? ( $1)
143
+ if extra_params . keys . include? ( $1)
144
+ delete_extra_param ( $1)
145
+ elsif respond_to? ( $1)
143
146
send ( $1)
144
147
else
145
148
match
@@ -172,6 +175,10 @@ def extra_params
172
175
end
173
176
end
174
177
178
+ def delete_extra_param ( key )
179
+ @extra_params . delete ( key . to_sym ) || @extra_params . delete ( key . to_s )
180
+ end
181
+
175
182
def set_param ( hash , param )
176
183
key = param [ :name ]
177
184
return hash if !respond_to? ( key ) || in_path? ( key )
Original file line number Diff line number Diff line change 125
125
end
126
126
end
127
127
end
128
+ end
129
+
130
+ put "/orders/:id" do
131
+ parameter :type , "The type of drink you want."
132
+ parameter :size , "The size of drink you want."
133
+ parameter :note , "Any additional notes about your order."
134
+
135
+ required_parameters :type , :size
136
+
137
+ let ( :type ) { "coffee" }
138
+ let ( :size ) { "medium" }
139
+
140
+ let ( :id ) { 1 }
128
141
129
142
describe "do_request" do
130
143
context "when raw_post is defined" do
152
165
client . should_receive ( method ) . with ( path , params . merge ( "size" => "large" ) )
153
166
do_request ( :size => "large" )
154
167
end
168
+
169
+ it "should overwrite path variables" do
170
+ client . should_receive ( method ) . with ( "/orders/2" , params )
171
+ do_request ( :id => 2 )
172
+ end
155
173
end
156
174
end
157
175
You can’t perform that action at this time.
0 commit comments