Sha256: 758f56f8cc21c1cc3f3725cf1e801b358d246797e241526317a53cbee6c8a293

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

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

describe Middleman::WebP::Logger do
  before do
    @thor_mock = stub({say_status: nil})
    @logger = Middleman::WebP::Logger.new(stub({thor: @thor_mock}))
  end

  it "logs info message through Thor with given color" do
    @thor_mock.expects(:say_status).once.with do |action, msg, color|
      msg == 'foobar' && color == :blue
    end
    @logger.info 'foobar', :blue
  end

  [[:error, :red], [:warn, :yellow]].each do |(method, color)|
    it "##{method} logs message with color #{color}" do
      @thor_mock.expects(:say_status).once.with do |action, msg, col|
        msg == "#{method} message" && col == color
      end
      @logger.send method, "#{method} message"
    end
  end

  it "logs error with red" do
    @thor_mock.expects(:say_status).once.with do |action, msg, color|
      msg == 'foobar' && color == :red
    end
    @logger.error 'foobar'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-webp-0.4.1 spec/unit/logger_spec.rb
middleman-webp-0.4.0 spec/unit/logger_spec.rb