Sha256: d402e3f9caba45b46c6b14b4caf6e72afeed450378de78c47ac184cad13a484d

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

class TwoStateMachines
  include SimplyFSM

  state_machine :motion do
    state :idling, initial: true
    state :walking

    event :idle, transition: { from: :any, to: :idling }
    event :walk, transition: { from: :idling, to: :walking }
  end

  state_machine :action do
    state :ready, initial: true
    state :blocking

    event :hold, transition: { from: :any, to: :ready }
    event :block, transition: { from: :any, to: :blocking }
  end
end

RSpec.describe TwoStateMachines do
  include_examples "state machine basics", :motion,
                   initial_state: :idling,
                   states: %i[idling walking],
                   events: %i[idle walk]

  include_examples "state machine basics", :action,
                   initial_state: :ready,
                   states: %i[ready blocking],
                   events: %i[hold block]
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simply_fsm-0.1.2 spec/unit/two_state_machines_spec.rb
simply_fsm-0.1.1 spec/unit/two_state_machines_spec.rb
simply_fsm-0.1.0 spec/unit/two_state_machines_spec.rb