Sha256: 4f9d3f7517d089febe27248aa7134cf2d2937fda7892d56f3fdf8154e59e593c

Contents?: true

Size: 1.2 KB

Versions: 57

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe Dragonfly::ImageMagick::Encoder do
  
  before(:all) do
    sample_file = File.dirname(__FILE__) + '/../../../samples/beach.png' # 280x355, 135KB
    @image = Dragonfly::TempObject.new(File.new(sample_file))
    @encoder = Dragonfly::ImageMagick::Encoder.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

57 entries across 57 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.7.4 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.7.3 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.7.2 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.7.1 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.7.0 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.9 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.8 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.7 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.6 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.5 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.4 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.3 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.2 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.1 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.6.0 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.5.17 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.5.16 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.5.15 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb
classiccms-0.5.14 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/image_magick/encoder_spec.rb