Sha256: 0f3778794bb2711587113a13868df2b77996365c84378d16da01d67d0ffd2d3e

Contents?: true

Size: 1.16 KB

Versions: 138

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

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

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 = Hash[
    ImageOptim::Worker.klasses.map do |klass|
      [klass.bin_sym, false]
    end
  ].merge(:skip_missing_workers => false)

  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

138 entries across 138 versions & 1 rubygems

Version Path
image_optim_pack-0.10.0.20231105-x86_64-linux spec/image_optim_spec.rb
image_optim_pack-0.10.0.20231105-x86_64-darwin spec/image_optim_spec.rb
image_optim_pack-0.10.0.20231105 spec/image_optim_spec.rb
image_optim_pack-0.10.0.20231014-x86_64-linux spec/image_optim_spec.rb
image_optim_pack-0.10.0.20231014-x86_64-darwin spec/image_optim_spec.rb
image_optim_pack-0.10.0.20231014 spec/image_optim_spec.rb
image_optim_pack-0.10.0-x86_64-linux spec/image_optim_spec.rb
image_optim_pack-0.10.0-x86_64-darwin spec/image_optim_spec.rb
image_optim_pack-0.10.0 spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230828 spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230828-x86_64-linux spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230828-x86_64-darwin spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230828-x86-linux spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230814-x86-linux spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230814-x86_64-linux spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230814-x86_64-darwin spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230814 spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230625-x86-linux spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230625-x86_64-linux spec/image_optim_spec.rb
image_optim_pack-0.9.1.20230625-x86_64-darwin spec/image_optim_spec.rb