@@ -21,7 +21,18 @@ Feature: Uploading a file
21
21
[200, {}, [request.params["post"]["file"][:filename]]]
22
22
end
23
23
end
24
- """
24
+ """
25
+ Given a file named "nested_param_in_array.rb" with:
26
+ """
27
+ require 'rack'
28
+
29
+ class App
30
+ def self.call(env)
31
+ request = Rack::Request.new(env)
32
+ [200, {}, [request.params["post"]["files"][0][:filename]]]
33
+ end
34
+ end
35
+ """
25
36
26
37
Scenario : Uploading a text file with nested parameters
27
38
Given a file named "file.txt" with:
@@ -40,7 +51,7 @@ Feature: Uploading a file
40
51
41
52
resource "FooBars" do
42
53
post "/foobar" do
43
- parameter :post, "Post paramter "
54
+ parameter :post, "Post parameter "
44
55
45
56
let(:post) do
46
57
{
@@ -161,6 +172,42 @@ Feature: Uploading a file
161
172
162
173
When I run `rspec app_spec.rb --require ./nestedparam.rb --format RspecApiDocumentation::ApiFormatter`
163
174
175
+ Then the output should contain "1 example, 0 failures"
176
+ And the exit status should be 0
177
+ And the generated documentation should be encoded correctly
178
+
179
+ Scenario : Uploading an image file in params array
180
+ Given I move the sample image into the workspace
181
+ And a file named "app_spec.rb" with:
182
+ """
183
+ require "rspec_api_documentation"
184
+ require "rspec_api_documentation/dsl"
185
+ require "rack/test"
186
+
187
+ RspecApiDocumentation.configure do |config|
188
+ config.app = App
189
+ end
190
+
191
+ resource "FooBars" do
192
+ post "/foobar" do
193
+ parameter :post, "Post parameter"
194
+
195
+ let(:post) do
196
+ {
197
+ id: 10,
198
+ files: [ Rack::Test::UploadedFile.new("file.png", "image/png") ]
199
+ }
200
+ end
201
+
202
+ example_request "Uploading a file" do
203
+ expect(response_body).to eq("file.png")
204
+ end
205
+ end
206
+ end
207
+ """
208
+
209
+ When I run `rspec app_spec.rb --require ./nested_param_in_array.rb --format RspecApiDocumentation::ApiFormatter`
210
+
164
211
Then the output should contain "1 example, 0 failures"
165
212
And the exit status should be 0
166
213
And the generated documentation should be encoded correctly
0 commit comments