Sha256: 4304832403ac91f2b1a9820cc2db6b1837a64253c0ac8e4e751b0e179d07c4ee

Contents?: true

Size: 897 Bytes

Versions: 4

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

class TwoStateMachines
  include SimplyFSM

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

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

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

    event :hold, transitions: { from: :any, to: :ready }
    event :block, transitions: { 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

4 entries across 4 versions & 1 rubygems

Version Path
simply_fsm-0.3.0 spec/unit/two_state_machines_spec.rb
simply_fsm-0.2.3 spec/unit/two_state_machines_spec.rb
simply_fsm-0.2.1 spec/unit/two_state_machines_spec.rb
simply_fsm-0.2.0 spec/unit/two_state_machines_spec.rb