Skip callbacks on Factory Girl and Rspec

前端 未结 16 1047
暗喜
暗喜 2020-12-12 12:17

I\'m testing a model with an after create callback that I\'d like to run only on some occasions while testing. How can I skip/run callbacks from a factory?

c         


        
16条回答
  •  情书的邮戳
    2020-12-12 13:00

    This will work with current rspec syntax (as of this post) and is much cleaner:

    before do
       User.any_instance.stub :run_something
    end
    

提交回复
热议问题