diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-20 08:52:48 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-20 08:52:48 +0100 |
commit | 206c5643aae40b0884d42fdb8caeb3f763936fa9 (patch) | |
tree | 608f5cc7daab7b58b3d159429c595303e7e1c7d4 /activemodel/test/state_machine/state_transition_test.rb | |
parent | fb1eebac940d0648d1640d20a24f085d901d6f30 (diff) | |
parent | 20a346170cf3922d16e265487cfb1abcc85383c1 (diff) | |
download | rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.tar.gz rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.tar.bz2 rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activemodel/test/state_machine/state_transition_test.rb')
-rw-r--r-- | activemodel/test/state_machine/state_transition_test.rb | 104 |
1 files changed, 50 insertions, 54 deletions
diff --git a/activemodel/test/state_machine/state_transition_test.rb b/activemodel/test/state_machine/state_transition_test.rb index 5165bb1c97..b59ff5a6a7 100644 --- a/activemodel/test/state_machine/state_transition_test.rb +++ b/activemodel/test/state_machine/state_transition_test.rb @@ -10,39 +10,37 @@ class StateTransitionTest < ActiveModel::TestCase assert_equal opts, st.options end - uses_mocha 'checking ActiveModel StateMachine transitions' do - test 'should pass equality check if from and to are the same' do - opts = {:from => 'foo', :to => 'bar', :guard => 'g'} - st = ActiveModel::StateMachine::StateTransition.new(opts) + test 'should pass equality check if from and to are the same' do + opts = {:from => 'foo', :to => 'bar', :guard => 'g'} + st = ActiveModel::StateMachine::StateTransition.new(opts) - obj = stub - obj.stubs(:from).returns(opts[:from]) - obj.stubs(:to).returns(opts[:to]) + obj = stub + obj.stubs(:from).returns(opts[:from]) + obj.stubs(:to).returns(opts[:to]) - assert_equal st, obj - end + assert_equal st, obj + end - test 'should fail equality check if from are not the same' do - opts = {:from => 'foo', :to => 'bar', :guard => 'g'} - st = ActiveModel::StateMachine::StateTransition.new(opts) + test 'should fail equality check if from are not the same' do + opts = {:from => 'foo', :to => 'bar', :guard => 'g'} + st = ActiveModel::StateMachine::StateTransition.new(opts) - obj = stub - obj.stubs(:from).returns('blah') - obj.stubs(:to).returns(opts[:to]) + obj = stub + obj.stubs(:from).returns('blah') + obj.stubs(:to).returns(opts[:to]) - assert_not_equal st, obj - end - - test 'should fail equality check if to are not the same' do - opts = {:from => 'foo', :to => 'bar', :guard => 'g'} - st = ActiveModel::StateMachine::StateTransition.new(opts) + assert_not_equal st, obj + end + + test 'should fail equality check if to are not the same' do + opts = {:from => 'foo', :to => 'bar', :guard => 'g'} + st = ActiveModel::StateMachine::StateTransition.new(opts) - obj = stub - obj.stubs(:from).returns(opts[:from]) - obj.stubs(:to).returns('blah') + obj = stub + obj.stubs(:from).returns(opts[:from]) + obj.stubs(:to).returns('blah') - assert_not_equal st, obj - end + assert_not_equal st, obj end end @@ -54,35 +52,33 @@ class StateTransitionGuardCheckTest < ActiveModel::TestCase assert st.perform(nil) end - uses_mocha 'checking ActiveModel StateMachine transition guard checks' do - test 'should call the method on the object if guard is a symbol' do - opts = {:from => 'foo', :to => 'bar', :guard => :test_guard} - st = ActiveModel::StateMachine::StateTransition.new(opts) - - obj = stub - obj.expects(:test_guard) - - st.perform(obj) - end - - test 'should call the method on the object if guard is a string' do - opts = {:from => 'foo', :to => 'bar', :guard => 'test_guard'} - st = ActiveModel::StateMachine::StateTransition.new(opts) - - obj = stub - obj.expects(:test_guard) - - st.perform(obj) - end - - test 'should call the proc passing the object if the guard is a proc' do - opts = {:from => 'foo', :to => 'bar', :guard => Proc.new {|o| o.test_guard}} - st = ActiveModel::StateMachine::StateTransition.new(opts) + test 'should call the method on the object if guard is a symbol' do + opts = {:from => 'foo', :to => 'bar', :guard => :test_guard} + st = ActiveModel::StateMachine::StateTransition.new(opts) + + obj = stub + obj.expects(:test_guard) - obj = stub - obj.expects(:test_guard) + st.perform(obj) + end + + test 'should call the method on the object if guard is a string' do + opts = {:from => 'foo', :to => 'bar', :guard => 'test_guard'} + st = ActiveModel::StateMachine::StateTransition.new(opts) + + obj = stub + obj.expects(:test_guard) - st.perform(obj) - end + st.perform(obj) + end + + test 'should call the proc passing the object if the guard is a proc' do + opts = {:from => 'foo', :to => 'bar', :guard => Proc.new {|o| o.test_guard}} + st = ActiveModel::StateMachine::StateTransition.new(opts) + + obj = stub + obj.expects(:test_guard) + + st.perform(obj) end end |