Skip callbacks on Factory Girl and Rspec

前端 未结 16 1044
暗喜
暗喜 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条回答
  •  猫巷女王i
    2020-12-12 13:08

    A simple stub worked best for me in Rspec 3

    allow_any_instance_of(User).to receive_messages(:run_something => nil)
    

提交回复
热议问题