class EventCollectionAttributeWithMachineActionTest
Public Instance Methods
save()
click to toggle source
# File test/unit/event_collection_test.rb, line 171 def save end
setup()
click to toggle source
# File test/unit/event_collection_test.rb, line 169 def setup @klass = Class.new do def save end end @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save) @events = StateMachine::EventCollection.new(@machine) @machine.state :parked, :idling @events << @ignite = StateMachine::Event.new(@machine, :ignite) @machine.events.concat(@events) @object = @klass.new end
test_should_have_invalid_transition_if_event_cannot_be_fired()
click to toggle source
# File test/unit/event_collection_test.rb, line 200 def test_should_have_invalid_transition_if_event_cannot_be_fired @object.state_event = 'ignite' assert_equal false, @events.attribute_transition_for(@object) end
test_should_have_invalid_transition_if_invalid_event_specified()
click to toggle source
# File test/unit/event_collection_test.rb, line 195 def test_should_have_invalid_transition_if_invalid_event_specified @object.state_event = 'invalid' assert_equal false, @events.attribute_transition_for(@object) end
test_should_have_valid_transition_if_already_defined_in_transition_cache()
click to toggle source
# File test/unit/event_collection_test.rb, line 212 def test_should_have_valid_transition_if_already_defined_in_transition_cache @ignite.transition :parked => :idling @object.state_event = nil @object.send(:state_event_transition=, transition = @ignite.transition_for(@object)) assert_equal transition, @events.attribute_transition_for(@object) end
test_should_have_valid_transition_if_event_can_be_fired()
click to toggle source
# File test/unit/event_collection_test.rb, line 205 def test_should_have_valid_transition_if_event_can_be_fired @ignite.transition :parked => :idling @object.state_event = 'ignite' assert_instance_of StateMachine::Transition, @events.attribute_transition_for(@object) end
test_should_not_have_transition_if_empty()
click to toggle source
# File test/unit/event_collection_test.rb, line 190 def test_should_not_have_transition_if_empty @object.state_event = '' assert_nil @events.attribute_transition_for(@object) end
test_should_not_have_transition_if_nil()
click to toggle source
# File test/unit/event_collection_test.rb, line 185 def test_should_not_have_transition_if_nil @object.state_event = nil assert_nil @events.attribute_transition_for(@object) end
test_should_use_transition_cache_if_both_event_and_transition_are_present()
click to toggle source
# File test/unit/event_collection_test.rb, line 220 def test_should_use_transition_cache_if_both_event_and_transition_are_present @ignite.transition :parked => :idling @object.state_event = 'ignite' @object.send(:state_event_transition=, transition = @ignite.transition_for(@object)) assert_equal transition, @events.attribute_transition_for(@object) end