AASM:两次调用防护方法

时间:2014-11-19 20:57:19

标签: ruby-on-rails rspec aasm

在使用aasm测试(Rspec)我的状态转换时,我注意到我的所有:guard方法都被调用了两次。

例如:

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

...

在我的RSpec中

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

... 但得到

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

我在这里做错了什么?

0 个答案:

没有答案