AASM: guard method being called twice

322 views Asked by At

While testing (Rspec) my state transitions using aasm I am noticing that all of my :guard methods are being called twice.

For example:

event :process_shipping_label do
  transitions :from => :label_generated, :to => :label_sent, :guard => :sent_shipping_label?
  transitions :from => :label_generated, :to => :label_send_failed
end

...

def sent_shipping_label?
  some_other_method_call  
end

...

In my RSpec

it "should call some_other_method_call exactly once" do
  package.should_receive(:some_other_method_call) {}
  package.process_shipping_label
end

... but getting

Failure/Error: package.should_receive(:some_other_method_call) {}
   (#<Artwork:0x007fafd5cbff48>).some_other_method_call?(any args)
       expected: 1 time
       received: 2 times

What am I doing wrong here?

0

There are 0 answers