spec/unit/converter_spec.rb in middleman-webp-0.2.5 vs spec/unit/converter_spec.rb in middleman-webp-0.2.6
- old
+ new
@@ -3,21 +3,32 @@
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'))
+ @app_mock = stub(inst: stub(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
d = @converter.destination_path(Pathname.new('build/images/sample.jpg'))
d.to_s.must_equal 'build/images/sample.webp'
end
end
+ describe '#destination_path with append_extension = true' do
+ before do
+ @converter = Middleman::WebP::Converter.new(@app_mock, {append_extension: true}, 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'
+ end
+ end
+
describe '#change_percentage' do
it 'returns how many percents smaller destination file is' do
@converter.change_percentage(10_000, 8746).must_equal '12.54 %'
end
@@ -66,10 +77,10 @@
it 'won\'t include ignored files' do
@converter = Middleman::WebP::Converter.new(@app_mock, {
ignore: [/jpg$/, '**/*.gif']
}, nil)
- files_to_include = [Pathname.new('spec/fixtures/empty.png')]
+ files_to_include = [Pathname.new('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 = {