Question

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?

Was it helpful?

Solution

This worked for me, which I feel is more concise.

self.fixture_path = Blorgh::Engine.root.join("test", "fixtures")

OTHER TIPS

This works for me

self.fixture_path = Rails.root.parent + "./fixtures/ads"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top