Sha256: 0eb1634ec9093c53d0b72063e61661d9cf709416499c401455b65338f24acdd8

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require './test/helper'

class FileAdapterTest < Test::Unit::TestCase
  context "a new instance" do
    setup do
      @file = File.new(fixture_file("5k.png"))
      @file.binmode
      @subject = Paperclip.io_adapters.for(@file)
    end

    should "get the right filename" do
      assert_equal "5k.png", @subject.original_filename
    end

    should "force binmode on tempfile" do
      assert @subject.instance_variable_get("@tempfile").binmode?
    end

    should "get the content type" do
      assert_equal "image/png", @subject.content_type
    end

    should "get the file's size" do
      assert_equal 4456, @subject.size
    end

    should "return false for a call to nil?" do
      assert ! @subject.nil?
    end

    should "generate a MD5 hash of the contents" do
      expected = Digest::MD5.file(@file.path).to_s
      assert_equal expected, @subject.fingerprint
    end

    should "read the contents of the file" do
      expected = @file.read
      assert expected.length > 0
      assert_equal expected, @subject.read
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paperclip-3.0.2 test/file_adapter_test.rb