Sha256: e00352c5172626ec29a1a385c9ee81ea3c6fdbd7b0e354206c431f37fb2c69b5

Contents?: true

Size: 1.74 KB

Versions: 10

Compression:

Stored size: 1.74 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

png_path = File.dirname(__FILE__) + '/../../../samples/egg.png'

describe Dragonfly::Analysis::FileCommandAnalyser do
  
  before(:each) do
    @analyser = Dragonfly::Analysis::FileCommandAnalyser.new
  end
  
  describe "mime_type" do
    
    describe "when using the filesystem" do
      before(:each) do
        @analyser.use_filesystem = true
        @temp_object = Dragonfly::TempObject.new(File.new(png_path))
      end
      it "should give the mime-type" do
        @analyser.mime_type(@temp_object).should == 'image/png'
      end
      it "should not have initialized the data string" do
        @analyser.mime_type(@temp_object)
        @temp_object.instance_eval{@data}.should be_nil
      end
    end
    
    describe "when not using the filesystem" do
      before(:each) do
        @analyser.use_filesystem = false
        @temp_object = Dragonfly::TempObject.new(File.read(png_path))
      end
      it "should give the mime-type" do
        @analyser.mime_type(@temp_object).should == 'image/png'
      end
      it "should not have initialized the file" do
        @analyser.mime_type(@temp_object)
        @temp_object.instance_eval{@tempfile}.should be_nil
      end
      
      {
        :jpg => 'image/jpeg',
        :png => 'image/png',
        :gif => 'image/gif',
        :tif => 'image/tiff'
      }.each do |format, mime_type|
        it "should work properly (without a broken pipe error) for big files of format #{format}" do
          processor = Dragonfly::Processing::RMagickProcessor.new
          temp_object = Dragonfly::TempObject.new(processor.generate(1000, 1000, format))
          @analyser.mime_type(temp_object).should == mime_type
        end
      end
      
    end
  
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dragonfly-0.6.2 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.6.1 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.6.0 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.7 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.6 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.5 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.4 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.3 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.2 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.5.1 spec/dragonfly/analysis/file_command_analyser_spec.rb