From 0ee1ad986fd777b852be7f57402167d13a37340f Mon Sep 17 00:00:00 2001 From: Scott Barron Date: Fri, 30 May 2008 16:33:27 -0700 Subject: [PATCH] coverage for event fired/failed method when using non-! methods --- spec/unit/aasm_spec.rb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/spec/unit/aasm_spec.rb b/spec/unit/aasm_spec.rb index dcc9a12..d42eee5 100644 --- a/spec/unit/aasm_spec.rb +++ b/spec/unit/aasm_spec.rb @@ -190,7 +190,7 @@ describe AASM, '- getting events for a state' do end describe AASM, '- event callbacks' do - it 'should call aasm_event_fired if defined and successful' do + it 'should call aasm_event_fired if defined and successful for bang fire' do foo = Foo.new def foo.aasm_event_fired(from, to) end @@ -200,7 +200,17 @@ describe AASM, '- event callbacks' do foo.close! end - it 'should call aasm_event_failed if defined and transition failed' do + it 'should call aasm_event_fired if defined and successful for non-bang fire' do + foo = Foo.new + def foo.aasm_event_fired(from, to) + end + + foo.should_receive(:aasm_event_fired) + + foo.close + end + + it 'should call aasm_event_failed if defined and transition failed for bang fire' do foo = Foo.new def foo.aasm_event_failed(event) end @@ -209,6 +219,16 @@ describe AASM, '- event callbacks' do foo.null! end + + it 'should call aasm_event_failed if defined and transition failed for non-bang fire' do + foo = Foo.new + def foo.aasm_event_failed(event) + end + + foo.should_receive(:aasm_event_failed) + + foo.null + end end