class TransitionCollectionValidTest
Public Class Methods
new()
click to toggle source
Calls superclass method
# File test/unit/transition_collection_test.rb, line 175 def initialize super @persisted = [] end
Public Instance Methods
setup()
click to toggle source
# File test/unit/transition_collection_test.rb, line 171 def setup @klass = Class.new do attr_reader :persisted def initialize super @persisted = [] end def state=(value) @persisted << 'state' if @persisted @state = value end def status=(value) @persisted << 'status' if @persisted @status = value end end @state = StateMachine::Machine.new(@klass, :initial => :parked) @state.state :idling @state.event :ignite @status = StateMachine::Machine.new(@klass, :status, :initial => :first_gear) @status.state :second_gear @status.event :shift_up @object = @klass.new @result = 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) ]).perform end
state=(value)
click to toggle source
# File test/unit/transition_collection_test.rb, line 180 def state=(value) @persisted << 'state' if @persisted @state = value end
status=(value)
click to toggle source
# File test/unit/transition_collection_test.rb, line 185 def status=(value) @persisted << 'status' if @persisted @status = value end
test_should_persist_each_state()
click to toggle source
# File test/unit/transition_collection_test.rb, line 210 def test_should_persist_each_state assert_equal 'idling', @object.state assert_equal 'second_gear', @object.status end
test_should_persist_in_order()
click to toggle source
# File test/unit/transition_collection_test.rb, line 215 def test_should_persist_in_order assert_equal ['state', 'status'], @object.persisted end
test_should_store_results_in_transitions()
click to toggle source
# File test/unit/transition_collection_test.rb, line 219 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 206 def test_should_succeed assert_equal true, @result end