class StateWithContextTest
Public Instance Methods
rpm()
click to toggle source
# File test/unit/state_test.rb, line 631 def rpm 1000 end
setup()
click to toggle source
# File test/unit/state_test.rb, line 617 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) @ancestors = @klass.ancestors @machine.states << @state = StateMachine::State.new(@machine, :idling) speed_method = nil rpm_method = nil @state.context do def speed 0 end speed_method = instance_method(:speed) def rpm 1000 end rpm_method = instance_method(:rpm) end @speed_method = speed_method @rpm_method = rpm_method end
speed()
click to toggle source
# File test/unit/state_test.rb, line 626 def speed 0 end
test_should_define_each_context_method_in_owner_class()
click to toggle source
# File test/unit/state_test.rb, line 646 def test_should_define_each_context_method_in_owner_class %w(speed rpm).each {|method| assert @klass.method_defined?(method)} end
test_should_include_context_methods_in_state_methods()
click to toggle source
# File test/unit/state_test.rb, line 655 def test_should_include_context_methods_in_state_methods assert_equal @speed_method, @state.methods[:speed] assert_equal @rpm_method, @state.methods[:rpm] end
test_should_include_new_module_in_owner_class()
click to toggle source
# File test/unit/state_test.rb, line 641 def test_should_include_new_module_in_owner_class assert_not_equal @ancestors, @klass.ancestors assert_equal 1, @klass.ancestors.size - @ancestors.size end
test_should_not_use_context_methods_as_owner_class_methods()
click to toggle source
# File test/unit/state_test.rb, line 650 def test_should_not_use_context_methods_as_owner_class_methods assert_not_equal @speed_method, @klass.instance_method(:speed) assert_not_equal @rpm_method, @klass.instance_method(:rpm) end