class StateWithValidMethodCallTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/state_test.rb, line 783 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) @ancestors = @klass.ancestors @machine.states << @state = StateMachine::State.new(@machine, :idling) @state.context do def speed(arg = nil) block_given? ? [arg, yield] : arg end end @object = @klass.new end
speed(arg = nil) { |] : arg| ... }
click to toggle source
# File test/unit/state_test.rb, line 789 def speed(arg = nil) block_given? ? [arg, yield] : arg end
test_should_not_raise_an_exception()
click to toggle source
# File test/unit/state_test.rb, line 797 def test_should_not_raise_an_exception assert_nothing_raised { @state.call(@object, :speed, lambda {raise}) } end
test_should_pass_arguments_through()
click to toggle source
# File test/unit/state_test.rb, line 801 def test_should_pass_arguments_through assert_equal 1, @state.call(@object, :speed, lambda {}, 1) end
test_should_pass_blocks_through()
click to toggle source
# File test/unit/state_test.rb, line 805 def test_should_pass_blocks_through assert_equal [nil, 1], @state.call(@object, :speed) {1} end
test_should_pass_both_arguments_and_blocks_through()
click to toggle source
# File test/unit/state_test.rb, line 809 def test_should_pass_both_arguments_and_blocks_through assert_equal [1, 2], @state.call(@object, :speed, lambda {}, 1) {2} end