Sha256: d5225abd764dfda3a83f0854efd2378ef715a6774881549a45595a03c3c07b88

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe Dragonfly::Encoding::ImageMagickEncoder do
  
  before(:all) do
    sample_file = File.dirname(__FILE__) + '/../../../samples/beach.png' # 280x355, 135KB
    @image = Dragonfly::TempObject.new(File.new(sample_file))
    @encoder = Dragonfly::Encoding::ImageMagickEncoder.new
  end
  
  describe "#encode" do
    
    it "should encode the image to the correct format" do
      image = @encoder.encode(@image, :gif)
      image.should have_format('gif')
    end
    
    it "should throw :unable_to_handle if the format is not handleable" do
      lambda{
        @encoder.encode(@image, :goofy)
      }.should throw_symbol(:unable_to_handle)
    end
    
    it "should do nothing if the image is already in the correct format" do
      image = @encoder.encode(@image, :png)
      image.should == @image
    end

    it "should allow for extra args" do
      image = @encoder.encode(@image, :jpg, '-quality 1')
      image.should have_format('jpeg')
      image.should have_size('1.45KB')
    end
    
    it "should still work even if the image is already in the correct format and args are given" do
      image = @encoder.encode(@image, :png, '-quality 1')
      image.should_not == @image
    end
  end
  
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
dragonfly-0.8.6 spec/dragonfly/encoding/image_magick_encoder_spec.rb
dragonfly-0.8.5 spec/dragonfly/encoding/image_magick_encoder_spec.rb
dragonfly-0.8.4 spec/dragonfly/encoding/image_magick_encoder_spec.rb
fog-dragonfly-0.8.2 spec/dragonfly/encoding/image_magick_encoder_spec.rb
dragonfly-0.8.2 spec/dragonfly/encoding/image_magick_encoder_spec.rb
fog-dragonfly-0.8.1 spec/dragonfly/encoding/image_magick_encoder_spec.rb
dragonfly-0.8.1 spec/dragonfly/encoding/image_magick_encoder_spec.rb
dragonfly-0.8.0 spec/dragonfly/encoding/image_magick_encoder_spec.rb