Sha256: e99c5d9265bcea7f134ada83124eaa95a1913f064cebf221b6a7b733a18825f4

Contents?: true

Size: 982 Bytes

Versions: 1

Compression:

Stored size: 982 Bytes

Contents

# encoding: utf-8

require 'spec_helper'
require 'logger'

describe FiniteMachine::Logger do
  let(:message) { 'error' }
  let(:log) { double }

  subject(:logger) { described_class }

  before { allow(FiniteMachine).to receive(:logger) { log } }

  it "debugs message call" do
    expect(log).to receive(:debug).with(message)
    logger.debug(message)
  end

  it "informs message call" do
    expect(log).to receive(:info).with(message)
    logger.info(message)
  end

  it "warns message call" do
    expect(log).to receive(:warn).with(message)
    logger.warn(message)
  end

  it "errors message call" do
    expect(log).to receive(:error).with(message)
    logger.error(message)
  end

  it "reports transition" do
    expect(log).to receive(:info).with("Transition: @event=go red -> green")
    machine = double(:machine, current: :green)
    transition = double(:transition, name: "go", from_state: :red, machine: machine)
    logger.report_transition(transition)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
finite_machine-0.10.0 spec/unit/logger_spec.rb