class TransitionCollectionWithAfterCallbackHaltTest
Public Instance Methods
save()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1070 def save @saved = true end
setup()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1066 def setup @klass = Class.new do attr_reader :saved def save @saved = true end end @before_count = 0 @after_count = 0 @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save) @machine.state :idling @machine.event :ignite @machine.before_transition {@before_count += 1} @machine.after_transition {@after_count += 1; throw :halt} @machine.after_transition {@after_count += 1} @machine.around_transition {|block| @before_count += 1; block.call; @after_count += 1} @object = @klass.new @transitions = StateMachine::TransitionCollection.new([ StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling) ]) @result = @transitions.perform end
test_should_not_run_further_after_callbacks()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1106 def test_should_not_run_further_after_callbacks assert_equal 2, @after_count end
test_should_persist_state()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1098 def test_should_persist_state assert_equal 'idling', @object.state end
test_should_run_before_callbacks()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1102 def test_should_run_before_callbacks assert_equal 2, @before_count end
test_should_succeed()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1094 def test_should_succeed assert_equal true, @result end