I've extracted my models into a mountable engine and now I want the host-app (the app including that mountable engine) to use the fixtures from that engine.
class ActiveSupport::TestCase
# Add fixtures from the mounted engine "blorgh"
fixture_path = Blorgh::Engine.root.join("test", "fixtures")
fixtures :all
end
Debugging learns that fixture_path is correctly set, to something like /home/x/.rvm/gems/ruby-1.9.3-p286@x/bundler/gems/blorgh-07520673953b/test/fixtures/
. This is the correct path with the correct fixtures.
But, somehow the fixtures appear not to get loaded. The database remains empty. And the helpers are not available. E.g. a fixture contacts.yml
normally leads to the helper contacts(:harry)
. This helper is not set, because the fixtures were not loaded.
The engine is not namespaced, but for the sake of completeness, blorgh_contacts(:harry)
is not defined either.
How can I use the fixtures from an engine?
This worked for me, which I feel is more concise.
self.fixture_path = Blorgh::Engine.root.join("test", "fixtures")