Sha256: 1272fba2a0cf005392b00b9fe9a7c4e7ceef7f8fc777c89ab6f808610158c55d

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

RSpec.describe FiniteMachine, '#states' do
  it "retrieves all available states" do
    fsm = FiniteMachine.new do
      initial :green

      event :slow,  :green  => :yellow
      event :stop,  :yellow => :red
      event :ready, :red    => :yellow
      event :go,    :yellow => :green
    end

    expect(fsm.states).to match_array([:none, :green, :yellow, :red])
  end

  it "retrieves all unique states for choice transition" do
    fsm = FiniteMachine.new do
      initial :green

      event :next, from: :green do
        choice :yellow, if: -> { false }
        choice :red,    if: -> { true }
      end
    end
    expect(fsm.states).to match_array([:none, :green, :yellow, :red])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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