make spec match reality

This commit is contained in:
Travis Tilley 2009-06-07 03:41:04 -04:00
parent 439a5f99a4
commit 294b1ba15a
1 changed files with 12 additions and 4 deletions

View File

@ -3,8 +3,16 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
class Foo2
include AASM
aasm_initial_state :open
aasm_state :open, :before_enter => :before_enter_open, :before_exit => :before_exit_open, :after_enter => :after_enter_open, :after_exit => :after_exit_open
aasm_state :closed, :before_enter => :before_enter_closed, :before_exit => :before_exit_closed, :after_enter => :after_enter_closed, :after_exit => :after_exit_closed
aasm_state :open,
:before_enter => :before_enter_open,
:before_exit => :before_exit_open,
:after_enter => :after_enter_open,
:after_exit => :after_exit_open
aasm_state :closed,
:before_enter => :before_enter_closed,
:before_exit => :before_exit_closed,
:after_enter => :after_enter_closed,
:after_exit => :after_exit_closed
aasm_event :close, :before => :before, :after => :after do
transitions :to => :closed, :from => [:open]
@ -44,9 +52,9 @@ describe Foo2, '- new callbacks' do
end
it "should get close callbacks" do
@foo.should_receive(:before).once.ordered
@foo.should_receive(:before_exit_open).once.ordered # these should be before the state changes
@foo.should_receive(:before_enter_closed).once.ordered
@foo.should_receive(:before).once.ordered
@foo.should_receive(:aasm_write_state).once.ordered.and_return(true) # this is when the state changes
@foo.should_receive(:after_exit_open).once.ordered # these should be after the state changes
@foo.should_receive(:after_enter_closed).once.ordered
@ -58,9 +66,9 @@ describe Foo2, '- new callbacks' do
it "should get open callbacks" do
@foo.close!
@foo.should_receive(:before).once.ordered
@foo.should_receive(:before_exit_closed).once.ordered # these should be before the state changes
@foo.should_receive(:before_enter_open).once.ordered
@foo.should_receive(:before).once.ordered
@foo.should_receive(:aasm_write_state).once.ordered.and_return(true) # this is when the state changes
@foo.should_receive(:after_exit_closed).once.ordered # these should be after the state changes
@foo.should_receive(:after_enter_open).once.ordered