Class: StateCollectionWithCustomStateValuesTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- StateCollectionWithCustomStateValuesTest
- Defined in:
- lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_should_find_state_for_object_if_value_is_known ⇒ Object
- #test_should_match_if_value_matches ⇒ Object
- #test_should_not_match_if_value_does_not_match ⇒ Object
Instance Method Details
#setup ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb', line 83 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) @states = StateMachine::StateCollection.new(@machine) @states << @state = StateMachine::State.new(@machine, :parked, :value => 1) @object = @klass.new @object.state = 1 end |
#test_should_find_state_for_object_if_value_is_known ⇒ Object
103 104 105 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb', line 103 def test_should_find_state_for_object_if_value_is_known assert_equal @state, @states.match(@object) end |
#test_should_match_if_value_matches ⇒ Object
94 95 96 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb', line 94 def test_should_match_if_value_matches assert @states.matches?(@object, :parked) end |
#test_should_not_match_if_value_does_not_match ⇒ Object
98 99 100 101 |
# File 'lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb', line 98 def test_should_not_match_if_value_does_not_match @object.state = 2 assert !@states.matches?(@object, :parked) end |