Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

A More Kosher Approach to Spork

Onsi Fakhouri
Thursday, December 1, 2011

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 load (not require because 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.

Interesting Things

  • 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).
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Add New Comment Cancel reply

Your email address will not be published.

Onsi Fakhouri

Onsi Fakhouri
San Francisco

Recent Posts

  • Cocktail: DRY up your backbone code with mixins
  • Coccyx: plug up those backbone leaks
  • [SF] Standup 4/26/2012: Hush Terminal, Hush
Subscribe to Onsi's Feed

Author Topics

backbone (2)
javascript (2)
agile (12)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >