Saturday, April 13, 2013

Factory Girl & after_initialize

If you're using Factory Girl with your RSpec tests and you are using the after_initialize callback, you might be wondering why your tests aren't passing, and then come to realize that the after_initialize callback event is never triggering. Luckily, there's a simple fix. Be sure to add something like this...

after(:build) {|instanace| instance.after_initialize_callback_method }

inside of your factory.