Sha256: 19451bf5325799e6d5bece927dc309d83e80221bbb8fb9d0fb56c9bb092793fa

Contents?: true

Size: 1007 Bytes

Versions: 14

Compression:

Stored size: 1007 Bytes

Contents

require_relative '../../test_helper'

class EventWithoutMatchingTransitionsTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass)
    @machine.state :parked, :idling

    @machine.events << @event = StateMachines::Event.new(@machine, :ignite)
    @event.transition(parked: :idling)

    @object = @klass.new
    @object.state = 'idling'
  end

  def test_should_not_be_able_to_fire
    refute @event.can_fire?(@object)
  end

  def test_should_be_able_to_fire_with_custom_from_state
    assert @event.can_fire?(@object, from: :parked)
  end

  def test_should_not_have_a_transition
    assert_nil @event.transition_for(@object)
  end

  def test_should_have_a_transition_with_custom_from_state
    refute_nil @event.transition_for(@object, from: :parked)
  end

  def test_should_not_fire
    refute @event.fire(@object)
  end

  def test_should_not_change_the_current_state
    @event.fire(@object)
    assert_equal 'idling', @object.state
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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