spec/integration/extension_spec.rb in middleman-webp-0.4.0 vs spec/integration/extension_spec.rb in middleman-webp-0.4.1
- old
+ new
@@ -1,16 +1,20 @@
require 'spec_helper'
require 'middleman-core'
require 'middleman-core/cli'
+require 'thor'
require_relative '../../lib/middleman-webp/extension'
+class MockBuilder
+ def thor
+ return Middleman::Cli::Build.new
+ end
+end
+
describe Middleman::WebPExtension do
before do
- @builder = Middleman::Cli::Build.new
- #@builder.stubs(:thor).with do |action, msg, opts|
- # action == :webp and msg =~ /Please install latest version of webp/
- #end
+ @builder = MockBuilder.new
end
after do
# Remove temporarily created files
Dir.glob('spec/fixtures/ok-build/**/*.webp').each do |file|
@@ -61,11 +65,14 @@
after_configuration: nil,
before_build: nil,
after_build: nil,
verbose: true,
root: '.',
- config: {source: 'spec/fixtures/ok-source'}
+ config: {
+ source: 'spec/fixtures/ok-source',
+ build_dir: 'spec/fixtures/ok-build'
+ }
})
Middleman::WebP::Logger.any_instance.expects(:info).once.with do |msg, c|
msg =~ /Total conversion savings/
end
@@ -96,10 +103,13 @@
instance_available: true,
after_configuration: nil,
before_build: nil,
after_build: nil,
root: '.',
- config: {build_dir: 'spec/fixtures/ok-build'}
+ config: {
+ source: 'spec/fixtures/ok-source',
+ build_dir: 'spec/fixtures/ok-build'
+ }
})
Middleman::WebP::Logger.any_instance.expects(:info).twice.with do |msg|
msg =~ /\.webp \([0-9.]+ % smaller\)/
end