Sha256: 6c3bf7bcda4494192ee656c74e46596f37502762d2957d2167f04ed65b59e1c9

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

RSpec.describe FiniteMachine::Logger do
  let(:message) { 'error' }
  let(:log) { spy }

  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
    logger.report_transition(:go, :red, :green)

    expect(log).to have_received(:info).with("Transition: @event=go red -> green")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finite_machine-0.12.1 spec/unit/logger_spec.rb
finite_machine-0.12.0 spec/unit/logger_spec.rb