following @stiff, and writing a better test :)

This commit is contained in:
Thorsten Böttger 2014-09-29 22:23:25 +02:00
parent 30745dc5f5
commit da237f0ed4
1 changed files with 6 additions and 3 deletions

View File

@ -171,15 +171,18 @@ describe AASM::Transition, '- when executing the transition with a Proc' do
end
it 'should call a Proc on the object without args' do
prc = Proc.new {||}
# in order to test that the Proc has been called, we make sure
# that after running the :after callback the prc_object is set
prc_object = nil
prc = Proc.new { prc_object = self }
opts = {:from => 'foo', :to => 'bar', :after => prc }
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = double('object', :aasm => 'aasm')
obj.should_receive(:instance_exec).with(no_args) # FIXME bad spec
st.execute(obj, args)
expect(prc_object).to eql obj
end
end