Sha256: 8200d46af4e1627776188263e0b43a679006029a4681f8296326d17ef07eeeb0

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'image_optim'
require 'image_optim/cmd'
require 'tempfile'
require 'English'

describe ImageOptim do
  before do
    stub_const('Cmd', ImageOptim::Cmd)
  end

  # grab images from image_optim gem
  image_optim_root = Gem.loaded_specs['image_optim'].gem_dir
  images_dir = FSPath.new(image_optim_root) / 'spec/images'
  test_images = images_dir.glob('**/*.*')

  isolated_options_base = {:skip_missing_workers => false}
  ImageOptim::Worker.klasses.each do |klass|
    isolated_options_base[klass.bin_sym] = false
  end

  ImageOptim::Worker.klasses.each do |worker_klass|
    next if [:pngout, :svgo].include?(worker_klass.bin_sym)

    describe "#{worker_klass.bin_sym} worker" do
      it 'optimizes at least one test image' do
        options = isolated_options_base.merge(worker_klass.bin_sym => true)

        image_optim = ImageOptim.new(options)
        if Array(worker_klass.init(image_optim)).empty?
          image_optim = ImageOptim.new(options.merge(:allow_lossy => true))
        end

        expect(test_images.any? do |original|
          image_optim.optimize_image(original)
        end).to be true
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
image_optim_pack-0.3.0.20161206 spec/image_optim_spec.rb
image_optim_pack-0.3.0.20161108 spec/image_optim_spec.rb
image_optim_pack-0.3.0.20161021 spec/image_optim_spec.rb
image_optim_pack-0.3.0.20160927 spec/image_optim_spec.rb
image_optim_pack-0.3.0.20160905 spec/image_optim_spec.rb
image_optim_pack-0.3.0.20160812 spec/image_optim_spec.rb
image_optim_pack-0.3.0.20160806 spec/image_optim_spec.rb
image_optim_pack-0.3.0 spec/image_optim_spec.rb
image_optim_pack-0.2.3 spec/image_optim_spec.rb
image_optim_pack-0.2.2 spec/image_optim_spec.rb
image_optim_pack-0.2.1.20160610 spec/image_optim_spec.rb