spec/unit/converter_spec.rb in middleman-webp-0.3.2 vs spec/unit/converter_spec.rb in middleman-webp-0.4.0
- old
+ new
@@ -3,11 +3,11 @@
require 'middleman-core'
require_relative '../../lib/middleman-webp/converter'
describe Middleman::WebP::Converter do
before do
- @app_mock = stub(inst: stub(build_dir: 'spec/fixtures/dummy-build'))
+ @app_mock = stub(config: {build_dir: 'spec/fixtures/dummy-build'})
@converter = Middleman::WebP::Converter.new(@app_mock, {}, nil)
end
describe '#destination_path' do
it 'returns file name with same basename and webp suffix' do
@@ -16,11 +16,11 @@
end
end
describe '#destination_path with append_extension = true' do
before do
- @converter = Middleman::WebP::Converter.new(@app_mock, {append_extension: true}, nil)
+ @converter = Middleman::WebP::Converter.new(@app_mock, {append_extension: true}, nil, nil)
end
it 'returns file name with same basename and webp suffix' do
d = @converter.destination_path(Pathname.new('build/images/sample.jpg'))
d.to_s.must_equal 'build/images/sample.jpg.webp'
@@ -58,16 +58,13 @@
path = Pathname.new('/some/path/image.gif')
@converter.tool_for(path).must_equal 'gif2webp'
end
it 'uses cwebp for jpeg, png and tiff files' do
- path = Pathname.new('/some/path/image.jpg')
- @converter.tool_for(path).must_equal 'cwebp'
- path = Pathname.new('/some/path/image.png')
- @converter.tool_for(path).must_equal 'cwebp'
- path = Pathname.new('/some/path/image.tiff')
- @converter.tool_for(path).must_equal 'cwebp'
+ @converter.tool_for(Pathname('/some/path/image.jpg')).must_equal 'cwebp'
+ @converter.tool_for(Pathname('/some/path/image.png')).must_equal 'cwebp'
+ @converter.tool_for(Pathname('/some/path/image.tiff')).must_equal 'cwebp'
end
end
describe '#image_files' do
it 'includes all image files in Middleman build dir' do
@@ -75,20 +72,20 @@
end
it 'won\'t include ignored files' do
@converter = Middleman::WebP::Converter.new(@app_mock, {
ignore: [/jpg$/, '**/*.gif']
- }, nil)
+ }, nil, nil)
- files_to_include = [Pathname.new('spec/fixtures/dummy-build/empty.png')]
+ files_to_include = [Pathname('spec/fixtures/dummy-build/empty.png')]
@converter.image_files.must_equal files_to_include
end
it 'won\'t include files rejected by given proc' do
options = {
ignore: ->(path) { path.end_with? 'jpg' }
}
- @converter = Middleman::WebP::Converter.new(@app_mock, options, nil)
+ @converter = Middleman::WebP::Converter.new(@app_mock, options, nil, nil)
@converter.image_files.size.must_equal 2
end
end
end