Sha256: 475d3958509408873511494707626a6404a6efa8e7e166970dd1004aa2fab6dd

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require 'pathname'
require_relative '../../lib/middleman-webp/options'

describe Middleman::WebP::Options do
  describe '#for' do
    it 'returns cwebp args when given file matches option file pattern glob' do
      path = Pathname.new('test_image.jpg')
      options_hash = {
        conversion_options: {
          '*.jpg' => {
            lossless: true,
            q: 85
          }
        }
      }
      options = Middleman::WebP::Options.new options_hash

      args = options.for(path)
      args.must_match(/^(-q 85|-lossless) (-q 85|-lossless)$/)
    end

    it 'returns empty string when no options are defined' do
      path = Pathname.new('test_image.jpg')
      options = Middleman::WebP::Options.new

      args = options.for(path)
      args.must_be_empty
    end

    it 'returns cwebp args when given file matches option pattern regexp' do
      path = Pathname.new('test_image.jpg')
      options_hash = {
        conversion_options: {
          /jpg$/ => {
            q: 85
          }
        }
      }
      options = Middleman::WebP::Options.new options_hash

      args = options.for(path)
      args.must_match(/^-q 85$/)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
middleman-webp-0.2.6 spec/unit/options_spec.rb
middleman-webp-0.2.5 spec/unit/options_spec.rb
middleman-webp-0.2.4 spec/unit/options_spec.rb