Class: EventCollectionWithCustomMachineAttributeTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- EventCollectionWithCustomMachineAttributeTest
- Defined in:
- lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_should_have_valid_transition_if_event_can_be_fired ⇒ Object
- #test_should_not_have_transition_if_nil ⇒ Object
Instance Method Details
#setup ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb', line 299 def setup @klass = Class.new do def save end end @machine = StateMachine::Machine.new(@klass, :state, :attribute => :state_id, :initial => :parked, :action => :save) @events = StateMachine::EventCollection.new(@machine) @machine.event :ignite @machine.state :parked, :idling @events << @ignite = StateMachine::Event.new(@machine, :ignite) @object = @klass.new end |
#test_should_have_valid_transition_if_event_can_be_fired ⇒ Object
320 321 322 323 324 325 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb', line 320 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_nil ⇒ Object
315 316 317 318 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb', line 315 def test_should_not_have_transition_if_nil @object.state_event = nil assert_nil @events.attribute_transition_for(@object) end |