在使用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
我在这里做错了什么?