-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove uploaded data from multipart request body
See #39
- Loading branch information
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Given /^I move the sample image into the workspace$/ do | ||
FileUtils.cp("features/fixtures/file.png", current_dir) | ||
end | ||
|
||
Then /^the generated documentation should be encoded correctly$/ do | ||
file = File.read(File.join(current_dir, "doc", "api", "foobars", "uploading_a_file.html")) | ||
file.should =~ /file\.png/ | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
Feature: Uploading a file | ||
Background: | ||
Given a file named "app.rb" with: | ||
""" | ||
require 'rack' | ||
class App | ||
def self.call(env) | ||
request = Rack::Request.new(env) | ||
[200, {}, [request.params["file"][:filename]]] | ||
end | ||
end | ||
""" | ||
|
||
Scenario: Uploading a text file | ||
Given a file named "file.txt" with: | ||
""" | ||
a file to upload | ||
""" | ||
And a file named "app_spec.rb" with: | ||
""" | ||
require "rspec_api_documentation" | ||
require "rspec_api_documentation/dsl" | ||
require "rack/test" | ||
RspecApiDocumentation.configure do |config| | ||
config.app = App | ||
end | ||
resource "FooBars" do | ||
post "/foobar" do | ||
parameter :name, "Name of file" | ||
parameter :file, "File to upload" | ||
let(:name) { "my-new-file.txt" } | ||
let(:file) do | ||
Rack::Test::UploadedFile.new("file.txt", "text/plain") | ||
end | ||
example_request "Uploading a file" do | ||
response_body.should == "file.txt" | ||
end | ||
end | ||
end | ||
""" | ||
|
||
When I run `rspec app_spec.rb --require ./app.rb --format RspecApiDocumentation::ApiFormatter` | ||
|
||
Then the output should contain "1 example, 0 failures" | ||
And the exit status should be 0 | ||
|
||
Scenario: Uploading an image file | ||
Given I move the sample image into the workspace | ||
And a file named "app_spec.rb" with: | ||
""" | ||
require "rspec_api_documentation" | ||
require "rspec_api_documentation/dsl" | ||
require "rack/test" | ||
RspecApiDocumentation.configure do |config| | ||
config.app = App | ||
end | ||
resource "FooBars" do | ||
post "/foobar" do | ||
parameter :name, "Name of file" | ||
parameter :file, "File to upload" | ||
let(:name) { "my-new-file.txt" } | ||
let(:file) do | ||
Rack::Test::UploadedFile.new("file.png", "image/png") | ||
end | ||
example_request "Uploading a file" do | ||
response_body.should == "file.png" | ||
end | ||
end | ||
end | ||
""" | ||
|
||
When I run `rspec app_spec.rb --require ./app.rb --format RspecApiDocumentation::ApiFormatter` | ||
|
||
Then the output should contain "1 example, 0 failures" | ||
And the exit status should be 0 | ||
And the generated documentation should be encoded correctly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters