class TransitionCollectionWithSkippedActionsTest
Public Instance Methods
save_state()
click to toggle source
# File test/unit/transition_collection_test.rb, line 362 def save_state (@actions ||= []) << :save_state :save_state end
save_status()
click to toggle source
# File test/unit/transition_collection_test.rb, line 367 def save_status (@actions ||= []) << :save_status :save_status end
setup()
click to toggle source
# File test/unit/transition_collection_test.rb, line 358 def setup @klass = Class.new do attr_reader :actions def save_state (@actions ||= []) << :save_state :save_state end def save_status (@actions ||= []) << :save_status :save_status end end @callbacks = [] @state = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save_state) @state.state :idling @state.event :ignite @state.before_transition {@callbacks << :state_before} @state.after_transition {@callbacks << :state_after} @state.around_transition {|block| @callbacks << :state_around_before; block.call; @callbacks << :state_around_after} @status = StateMachine::Machine.new(@klass, :status, :initial => :first_gear, :action => :save_status) @status.state :second_gear @status.event :shift_up @status.before_transition {@callbacks << :status_before} @status.after_transition {@callbacks << :status_after} @status.around_transition {|block| @callbacks << :status_around_before; block.call; @callbacks << :status_around_after} @object = @klass.new @transitions = StateMachine::TransitionCollection.new([ @state_transition = StateMachine::Transition.new(@object, @state, :ignite, :parked, :idling), @status_transition = StateMachine::Transition.new(@object, @status, :shift_up, :first_gear, :second_gear) ], :actions => false) @result = @transitions.perform end
test_should_not_run_actions()
click to toggle source
# File test/unit/transition_collection_test.rb, line 411 def test_should_not_run_actions assert_nil @object.actions end
test_should_persist_states()
click to toggle source
# File test/unit/transition_collection_test.rb, line 406 def test_should_persist_states assert_equal 'idling', @object.state assert_equal 'second_gear', @object.status end
test_should_run_all_callbacks()
click to toggle source
# File test/unit/transition_collection_test.rb, line 420 def test_should_run_all_callbacks assert_equal [:state_before, :state_around_before, :status_before, :status_around_before, :status_around_after, :status_after, :state_around_after, :state_after], @callbacks end
test_should_skip_actions()
click to toggle source
# File test/unit/transition_collection_test.rb, line 398 def test_should_skip_actions assert_equal true, @transitions.skip_actions end
test_should_store_results_in_transitions()
click to toggle source
# File test/unit/transition_collection_test.rb, line 415 def test_should_store_results_in_transitions assert_nil @state_transition.result assert_nil @status_transition.result end
test_should_succeed()
click to toggle source
# File test/unit/transition_collection_test.rb, line 402 def test_should_succeed assert_equal true, @result end