From da237f0ed4552a5b4baf65fcf533ca806f55043e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20B=C3=B6ttger?= Date: Mon, 29 Sep 2014 22:23:25 +0200 Subject: [PATCH] following @stiff, and writing a better test :) --- spec/unit/transition_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/unit/transition_spec.rb b/spec/unit/transition_spec.rb index 589abea..9922419 100644 --- a/spec/unit/transition_spec.rb +++ b/spec/unit/transition_spec.rb @@ -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