class ActionDispatch::UploadedFileTest

Public Instance Methods

close(unlink_now = false) click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 69
def close(unlink_now = false); "thunderhorse" end
eof?() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 101
def eof?; true end
open() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 63
def open; "thunderhorse" end
path() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 57
def path; "thunderhorse" end
read(length = nil, buffer = nil) click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 81
def read(length = nil, buffer = nil); "thunderhorse" end
test_close_accepts_parameter() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 74
def test_close_accepts_parameter
  tf = Class.new { def close(unlink_now = false); "thunderhorse: #{unlink_now}" end }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert_equal "thunderhorse: true", uf.close(true)
end
test_constructor_with_argument_error() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 7
def test_constructor_with_argument_error
  assert_raises(ArgumentError) do
    Http::UploadedFile.new({})
  end
end
test_content_type() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 35
def test_content_type
  uf = Http::UploadedFile.new(type: "foo", tempfile: Object.new)
  assert_equal "foo", uf.content_type
end
test_delegate_eof_to_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 100
def test_delegate_eof_to_tempfile
  tf = Class.new { def eof?; true end; }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert uf.eof?
end
test_delegate_respects_respond_to?() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 92
    def test_delegate_respects_respond_to?
      tf = Class.new { def read; yield end; private :read }
      uf = Http::UploadedFile.new(tempfile: tf.new)
      assert_raises(NoMethodError) do
        uf.read
      end
    end

    def test_delegate_eof_to_tempfile
      tf = Class.new { def eof?; true end; }
      uf = Http::UploadedFile.new(tempfile: tf.new)
      assert uf.eof?
    end

    def test_respond_to?
      tf = Class.new { def read; yield end }
      uf = Http::UploadedFile.new(tempfile: tf.new)
      assert uf.respond_to?(:headers), "responds to headers"
      assert uf.respond_to?(:read), "responds to read"
    end
  end
end
test_delegates_close_to_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 68
def test_delegates_close_to_tempfile
  tf = Class.new { def close(unlink_now = false); "thunderhorse" end }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert_equal "thunderhorse", uf.close
end
test_delegates_open_to_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 62
def test_delegates_open_to_tempfile
  tf = Class.new { def open; "thunderhorse" end }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert_equal "thunderhorse", uf.open
end
test_delegates_path_to_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 56
def test_delegates_path_to_tempfile
  tf = Class.new { def path; "thunderhorse" end }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert_equal "thunderhorse", uf.path
end
test_delegates_read_to_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 80
def test_delegates_read_to_tempfile
  tf = Class.new { def read(length = nil, buffer = nil); "thunderhorse" end }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert_equal "thunderhorse", uf.read
end
test_delegates_read_to_tempfile_with_params() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 86
def test_delegates_read_to_tempfile_with_params
  tf = Class.new { def read(length = nil, buffer = nil); [length, buffer] end }
  uf = Http::UploadedFile.new(tempfile: tf.new)
  assert_equal %w{ thunder horse }, uf.read(*%w{ thunder horse })
end
test_filename_is_different_object() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 18
def test_filename_is_different_object
  file_str = "foo"
  uf = Http::UploadedFile.new(filename: file_str, tempfile: Object.new)
  assert_not_equal file_str.object_id , uf.original_filename.object_id
end
test_filename_should_always_be_in_utf_8() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 29
def test_filename_should_always_be_in_utf_8
  uf = Http::UploadedFile.new(filename: "foo".encode(Encoding::SHIFT_JIS),
                              tempfile: Object.new)
  assert_equal "UTF-8", uf.original_filename.encoding.to_s
end
test_filename_should_be_in_utf_8() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 24
def test_filename_should_be_in_utf_8
  uf = Http::UploadedFile.new(filename: "foo", tempfile: Object.new)
  assert_equal "UTF-8", uf.original_filename.encoding.to_s
end
test_headers() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 40
def test_headers
  uf = Http::UploadedFile.new(head: "foo", tempfile: Object.new)
  assert_equal "foo", uf.headers
end
test_original_filename() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 13
def test_original_filename
  uf = Http::UploadedFile.new(filename: "foo", tempfile: Object.new)
  assert_equal "foo", uf.original_filename
end
test_respond_to?() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 106
  def test_respond_to?
    tf = Class.new { def read; yield end }
    uf = Http::UploadedFile.new(tempfile: tf.new)
    assert uf.respond_to?(:headers), "responds to headers"
    assert uf.respond_to?(:read), "responds to read"
  end
end
test_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 45
def test_tempfile
  uf = Http::UploadedFile.new(tempfile: "foo")
  assert_equal "foo", uf.tempfile
end
test_to_io_returns_the_tempfile() click to toggle source
# File actionpack/test/dispatch/uploaded_file_test.rb, line 50
def test_to_io_returns_the_tempfile
  tf = Object.new
  uf = Http::UploadedFile.new(tempfile: tf)
  assert_equal tf, uf.to_io
end