spec/unit/state_transition_spec.rb in aasm-2.4.0 vs spec/unit/state_transition_spec.rb in aasm-3.0.0
- old
+ new
@@ -1,7 +1,23 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
+describe 'transitions' do
+
+ it 'should raise an exception when whiny' do
+ process = ProcessWithNewDsl.new
+ lambda { process.stop! }.should raise_error(AASM::InvalidTransition)
+ process.should be_sleeping
+ end
+
+ it 'should not raise an exception when whiny' do
+ silencer = Silencer.new
+ silencer.smile!.should be_false
+ silencer.should be_silent
+ end
+
+end
+
describe AASM::SupportingClasses::StateTransition do
it 'should set from, to, and opts attr readers' do
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
st = AASM::SupportingClasses::StateTransition.new(opts)
@@ -114,24 +130,24 @@
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj.should_receive(:test)
- st.execute(obj, args)
+ st.execute(obj, args)
end
-
+
it 'should accept a Symbol for the method name' do
opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
st = AASM::SupportingClasses::StateTransition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj.should_receive(:test)
- st.execute(obj, args)
+ st.execute(obj, args)
end
-
+
it 'should pass args if the target method accepts them' do
opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
st = AASM::SupportingClasses::StateTransition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
@@ -142,11 +158,11 @@
return_value = st.execute(obj, args)
return_value.should == 'success'
end
-
+
it 'should NOT pass args if the target method does NOT accept them' do
opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
st = AASM::SupportingClasses::StateTransition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
@@ -157,7 +173,7 @@
return_value = st.execute(obj, args)
return_value.should == 'success'
end
-
+
end