Sha256: 895b68c5e8199193cf67d05892c1791f3b1863c71bbcac2e6f350c8a3f232385

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require './test/helper'

class StringioFileProxyTest < Test::Unit::TestCase
  context "a new instance" do
    setup do
      @contents = "abc123"
      @stringio = StringIO.new(@contents)
      @subject = Paperclip.io_adapters.for(@stringio)
    end

    should "return a file name" do
      assert_equal "stringio.txt", @subject.original_filename
    end

    should "allow us to set a name" do
      @subject.original_filename = "data.txt"
      assert_equal "data.txt", @subject.original_filename
    end

    should "return a content type" do
      assert_equal "text/plain", @subject.content_type
    end

    should "allow us to set a content type" do
      @subject.content_type = "image/jpg"
      assert_equal "image/jpg", @subject.content_type
    end

    should "return the size of the data" do
      assert_equal 6, @subject.size
    end

    should "generate an MD5 hash of the contents" do
      assert_equal Digest::MD5.hexdigest(@contents), @subject.fingerprint
    end

    should "return the data contained in the StringIO" do
      assert_equal "abc123", @subject.read
    end

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
paperclip-3.0.4 test/io_adapters/stringio_adapter_test.rb
paperclip-3.0.3 test/io_adapters/stringio_adapter_test.rb
cloudfuji_paperclip-3.0.3 test/stringio_adapter_test.rb
paperclip-3.0.2 test/stringio_adapter_test.rb