Ask for Help
“Reloading of models under spork?”
From hybrid-cutlery expert Sobo:
Spork requires you to divide your spec helper into two phases, before fork and after fork.
Before fork, you want to do time consuming things like loading the Rails environment, so you don’t have to pay that cost on each test run.
If you end up requiring model classes or other volatile files before forking, then they won’t be reloaded for each test run.
This can happen, for example, when you use Devise route helpers, which touch the User constant during route evaluation.
This causes user.rb to be auto-required before fork.
Since the User constant is defined after forking, Rails won’t autoload changes to User, forcing you to restart the Spork server every time you change it.
There are two solutions:
- The first is simply to avoid loading models or other code you want to auto-reload before fork.
- If you must refer to models before fork, as is the case with the Devise route helpers, then put an explicit
requirebecause it won’t load the file if it’s already been loaded) in your after fork block for the files that were loaded before fork.
This will force them to be reloaded.
- It’s open season on open enrollment. SF will have an info session today at 12:30. Pizza will be served. Y’all have between now and December 9th to make changes.
- Those with mohawks and staches in SF are encouraged to take a picture at the Vermehr e-mail station (closest e-mail station to the bathrooms).
About the AuthorMore Content by Onsi Fakhouri