aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/state_machine/state_transition_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-03-20 10:32:24 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-03-20 10:32:24 +0000
commit5b1a1bf5bfc520248285b036672146122dd2a815 (patch)
tree31d82a9155db6c9e553888da6375bd89fdb122cf /activemodel/test/state_machine/state_transition_test.rb
parent93e2d378df5f599e3e48e74932f37e1c679f633e (diff)
downloadrails-5b1a1bf5bfc520248285b036672146122dd2a815.tar.gz
rails-5b1a1bf5bfc520248285b036672146122dd2a815.tar.bz2
rails-5b1a1bf5bfc520248285b036672146122dd2a815.zip
Make Active Model test suite similar to Active Record
Diffstat (limited to 'activemodel/test/state_machine/state_transition_test.rb')
-rw-r--r--activemodel/test/state_machine/state_transition_test.rb84
1 files changed, 0 insertions, 84 deletions
diff --git a/activemodel/test/state_machine/state_transition_test.rb b/activemodel/test/state_machine/state_transition_test.rb
deleted file mode 100644
index b59ff5a6a7..0000000000
--- a/activemodel/test/state_machine/state_transition_test.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require 'test_helper'
-
-class StateTransitionTest < ActiveModel::TestCase
- test 'should set from, to, and opts attr readers' do
- opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
- st = ActiveModel::StateMachine::StateTransition.new(opts)
-
- assert_equal opts[:from], st.from
- assert_equal opts[:to], st.to
- assert_equal opts, st.options
- end
-
- 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])
-
- 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)
-
- 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)
-
- obj = stub
- obj.stubs(:from).returns(opts[:from])
- obj.stubs(:to).returns('blah')
-
- assert_not_equal st, obj
- end
-end
-
-class StateTransitionGuardCheckTest < ActiveModel::TestCase
- test 'should return true of there is no guard' do
- opts = {:from => 'foo', :to => 'bar'}
- st = ActiveModel::StateMachine::StateTransition.new(opts)
-
- assert st.perform(nil)
- end
-
- 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)
-
- obj = stub
- obj.expects(:test_guard)
-
- st.perform(obj)
- end
-end