Sha256: e56c16f363340bad2b399b1d68680f60eaca2949eec801a5651dced6767616fc

Contents?: true

Size: 902 Bytes

Versions: 18

Compression:

Stored size: 902 Bytes

Contents

require 'spec_helper'

describe Paperclip::FileCommandContentTypeDetector do
  it 'returns a content type based on the content of the file' do
    tempfile = Tempfile.new("something")
    tempfile.write("This is a file.")
    tempfile.rewind

    assert_equal "text/plain", Paperclip::FileCommandContentTypeDetector.new(tempfile.path).detect

    tempfile.close
  end

  it 'returns a sensible default when the file command is missing' do
    Paperclip.stubs(:run).raises(Cocaine::CommandLineError.new)
    @filename = "/path/to/something"
    assert_equal "application/octet-stream",
      Paperclip::FileCommandContentTypeDetector.new(@filename).detect
  end

  it 'returns a sensible default on the odd chance that run returns nil' do
    Paperclip.stubs(:run).returns(nil)
    assert_equal "application/octet-stream",
      Paperclip::FileCommandContentTypeDetector.new("windows").detect
  end
end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
kt-paperclip-4.4.0 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-5.2.1 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-5.2.0 spec/paperclip/file_command_content_type_detector_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paperclip-5.1.0/spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-5.1.0 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-5.0.0 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.7 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip_jk-5.0.0.beta2 spec/paperclip/file_command_content_type_detector_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/paperclip-4.3.6/spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-5.0.0.beta2 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-5.0.0.beta1 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.6 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.5 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.4 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.3 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.2 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.1 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.3.0 spec/paperclip/file_command_content_type_detector_spec.rb