Parent

Rack::Test::UploadedFile

Wraps a Tempfile with a content type. Including one or more UploadedFile’s in the params causes Rack::Test to build and issue a multipart request.

Example:

  post "/photos", "file" => Rack::Test::UploadedFile.new("me.jpg", "image/jpeg")

Attributes

original_filename[R]

The filename, not including the path, of the “uploaded” file

content_type[RW]

The content type of the “uploaded” file

Public Class Methods

new(path, content_type = "text/plain", binary = false) click to toggle source
    # File lib/rack/test/uploaded_file.rb, line 20
20:       def initialize(path, content_type = "text/plain", binary = false)
21:         raise "#{path} file does not exist" unless ::File.exist?(path)
22: 
23:         @content_type = content_type
24:         @original_filename = ::File.basename(path)
25: 
26:         @tempfile = Tempfile.new(@original_filename)
27:         @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
28:         @tempfile.binmode if binary
29: 
30:         FileUtils.copy_file(path, @tempfile.path)
31:       end

Public Instance Methods

local_path() click to toggle source
Alias for: path
path() click to toggle source
    # File lib/rack/test/uploaded_file.rb, line 33
33:       def path
34:         @tempfile.path
35:       end
Also aliased as: local_path

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.