Sha256: 868e8f089ca6a83524d702f68edeaa4b5dd93e1a56fc63b05d2d7491b8867cf8

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

RSpec.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

2 entries across 2 versions & 1 rubygems

Version Path
finite_machine-0.10.2 spec/unit/logger_spec.rb
finite_machine-0.10.1 spec/unit/logger_spec.rb