Sha256: eab88ebbd6ad8eebd9d0234056485ecd4c129fb2efe9bdafd11b464e4d01cd26

Contents?: true

Size: 1.5 KB

Versions: 7

Compression:

Stored size: 1.5 KB

Contents

require '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
      it "should work properly (without a broken pipe error) for big files of format jpg" do
        data = Dragonfly::ImageMagick::Generator.new.plasma(1000, 1000, :jpg).first
        temp_object = Dragonfly::TempObject.new(data)
        @analyser.mime_type(temp_object).should == "image/jpeg"
      end
    end
  
  end
  
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
dragonfly-0.9.5 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.9.4 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.9.3 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.9.2 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.9.1 spec/dragonfly/analysis/file_command_analyser_spec.rb
dragonfly-0.9.0 spec/dragonfly/analysis/file_command_analyser_spec.rb
oahu-dragonfly-0.8.2 spec/dragonfly/analysis/file_command_analyser_spec.rb