I figured out my problem. It was actually Autotest and not Spork. I've moved from a mountable engine to a standard engine (plugin) since it ended up being a better fit for what I needed.
I'm now using the released version of Rails 3.1.
In this scenario, I figured things would be easier, but I encountered the same issue. Anyway, this ended up being the fix for testing a non-namespaced engine (mountable), although with a few path tweaks, I believe it will work.
Add an .autotest file to the root of the project with the following:
Autotest.add_hook :initialize do |at|
at.add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
"spec/models/#{m[1]}_spec.rb"
end
at.add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
["spec/controllers/#{m[1]}_spec.rb",
"spec/functional/#{m[1]}_spec.rb"]
end
at.add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
["spec/views/#{m[1]}_view_spec.rb",
"spec/functional/#{m[1]}_controller_spec.rb"]
end
at.add_mapping %r%^app/views/(.*)/% do |_, m|
["spec/views/#{m[1]}_view_spec.rb",
"spec/functional/#{m[1]}_controller_spec.rb"]
end
end
I came up with the solution when I ran across this answer on another question: how to tell autotest to correctly track changes in app source?, as well as other examples found around the web.
Hope this helps someone else out.
[Edit 2011-09-20]
Fixed the Cucumber/Spork problem with a "hack." Within the Spork.each_run block, I forced a reload of the models and controllers like so:
ENGINE_ROOT=File.join(File.dirname(__FILE__), '../../')
# Couldn't get spork to reload models, hence the reason for this hack
Dir[File.join(ENGINE_ROOT, "app/models/*.rb")].each {|f| load f }
# or controllers...
Dir[File.join(ENGINE_ROOT, "app/controllers/*.rb")].each {|f| load f }
It seems like there should be a better way...