Sha256: 49e317e7fd8d5d49e38518a136c7175a7264c136ced41e23188c55c1effabfcb

Contents?: true

Size: 1.06 KB

Versions: 14

Compression:

Stored size: 1.06 KB

Contents

require_relative '../../test_helper'

class TransitionAfterBeingPerformedTest < StateMachinesTest
  def setup
    @klass = Class.new do
      attr_reader :saved, :save_state

      def save
        @save_state = state
        @saved = true
        1
      end
    end

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

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

  def test_should_have_empty_args
    assert_equal [], @transition.args
  end

  def test_should_have_a_result
    assert_equal 1, @transition.result
  end

  def test_should_be_successful
    assert_equal true, @result
  end

  def test_should_change_the_current_state
    assert_equal 'idling', @object.state
  end

  def test_should_run_the_action
    assert @object.saved
  end

  def test_should_run_the_action_after_saving_the_state
    assert_equal 'idling', @object.save_state
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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