@@ -21,7 +21,18 @@ Feature: Uploading a file
2121 [200, {}, [request.params["post"]["file"][:filename]]]
2222 end
2323 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+ """
2536
2637 Scenario : Uploading a text file with nested parameters
2738 Given a file named "file.txt" with:
@@ -40,7 +51,7 @@ Feature: Uploading a file
4051
4152 resource "FooBars" do
4253 post "/foobar" do
43- parameter :post, "Post paramter "
54+ parameter :post, "Post parameter "
4455
4556 let(:post) do
4657 {
@@ -161,6 +172,42 @@ Feature: Uploading a file
161172
162173 When I run `rspec app_spec.rb --require ./nestedparam.rb --format RspecApiDocumentation::ApiFormatter`
163174
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+
164211 Then the output should contain "1 example, 0 failures"
165212 And the exit status should be 0
166213 And the generated documentation should be encoded correctly
0 commit comments