spec/unit/options_spec.rb in middleman-webp-1.0.1 vs spec/unit/options_spec.rb in middleman-webp-1.0.2

- old
+ new

@@ -4,16 +4,16 @@ describe Middleman::WebP::Options do describe '#allow_skip' do it 'should default to true' do options = Middleman::WebP::Options.new - options.allow_skip.must_equal(true) + value(options.allow_skip).must_equal(true) end it 'should allow setting to true' do options = Middleman::WebP::Options.new(allow_skip: false) - options.allow_skip.must_equal(false) + value(options.allow_skip).must_equal(false) end end describe '#for' do it 'returns cwebp args when given file matches option file pattern glob' do @@ -27,19 +27,19 @@ } } options = Middleman::WebP::Options.new options_hash args = options.for(path) - args.must_match(/^(-q 85|-lossless) (-q 85|-lossless)$/) + value(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 + value(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 = { @@ -50,9 +50,27 @@ } } options = Middleman::WebP::Options.new options_hash args = options.for(path) - args.must_match(/^-q 85$/) + value(args).must_match(/^-q 85$/) + end + + it 'selects most precise file pattern to get file specific option overrides correctly' do + path = Pathname.new('lizard.jpg') + options_hash = { + conversion_options: { + '*.jpg' => { + q: 85 + }, + 'lizard.jpg' => { + q: 100 + } + } + } + options = Middleman::WebP::Options.new options_hash + + args = options.for(path) + value(args).must_match(/^-q 100$/) end end end