Sha256: c738ed4e1d6aa451f55ee6f9dba0ad0aff6bd8de94d3d2f25bbb7c7a380eca8d

Contents?: true

Size: 703 Bytes

Versions: 1

Compression:

Stored size: 703 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe FiniteMachine, 'log_transitions' do
  let(:output) { StringIO.new('', 'w+')}

  before { FiniteMachine.logger = ::Logger.new(output) }

  after  { FiniteMachine.logger = ::Logger.new($stderr) }

  it "logs transitions" do
    fsm = FiniteMachine.define log_transitions: true do
      initial :green

      events {
        event :slow, :green  => :yellow
        event :stop, :yellow => :red
      }
    end

    fsm.slow
    output.rewind
    expect(output.read).to match(/Transition: @event=slow green -> yellow/)

    fsm.stop(1, 2)
    output.rewind
    expect(output.read).to match(/Transition: @event=stop @with=\[1,2\] yellow -> red/)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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