Sha256: 7baa6695e9f79895ff7dd7e8d1f5aecd327fbfd585065d68a14a6024cbaed22e

Contents?: true

Size: 841 Bytes

Versions: 14

Compression:

Stored size: 841 Bytes

Contents

require_relative '../../test_helper'

class MachineWithMultipleEventsTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass, initial: :parked)
    @park, @shift_down = @machine.event(:park, :shift_down) do
      transition first_gear: :parked
    end
  end

  def test_should_have_events
    assert_equal [@park, @shift_down], @machine.events.to_a
  end

  def test_should_define_transitions_for_each_event
    [@park, @shift_down].each { |event| assert_equal 1, event.branches.size }
  end

  def test_should_transition_the_same_for_each_event
    object = @klass.new
    object.state = 'first_gear'
    object.park
    assert_equal 'parked', object.state

    object = @klass.new
    object.state = 'first_gear'
    object.shift_down
    assert_equal 'parked', object.state
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-0.5.0 test/unit/machine/machine_with_multiple_events_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-0.2.2/test/unit/machine/machine_with_multiple_events_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-0.2.2/test/unit/machine/machine_with_multiple_events_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-0.2.2/test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.4.0 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.3.0 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.2.2 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.2.1 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.2.0 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.1.4 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.1.3 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.1.2 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.1.1 test/unit/machine/machine_with_multiple_events_test.rb
state_machines-0.1.0 test/unit/machine/machine_with_multiple_events_test.rb