Sha256: fdc6bea87e8f41d676ab362e3ca92c49f20d8d96baaa0bac47c740e51e56bd15

Contents?: true

Size: 865 Bytes

Versions: 14

Compression:

Stored size: 865 Bytes

Contents

require_relative '../../test_helper'

class TransitionWithoutCallbacksTest < StateMachinesTest
  def setup
    @klass = Class.new

    @machine = StateMachines::Machine.new(@klass)
    @machine.state :parked, :idling
    @machine.event :ignite

    @object = @klass.new
    @object.state = 'parked'
    @transition = StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling)
  end

  def test_should_succeed
    assert_equal true, @transition.run_callbacks
  end

  def test_should_succeed_if_after_callbacks_skipped
    assert_equal true, @transition.run_callbacks(after: false)
  end

  def test_should_call_block_if_provided
    @transition.run_callbacks { @ran_block = true; {} }
    assert @ran_block
  end

  def test_should_track_block_result
    @transition.run_callbacks { { result: 1 } }
    assert_equal 1, @transition.result
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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