A lot has been written about engine development, and using a dummy app for testing.
In our case we're developing an engine that is not a stand-alone entity, but has dependencies on a real Rails 3 application. We still want this code to live in an engine, and not become part of the app, because the engine's job is to import data from a legacy system that has its own tables and model mappings, and we want to eventually remove it again.
The data mappings between the old legacy tables and the new schema are complex, and we want to TDD (using rspec) the engine.
- I've followed Jose Valim's book "Crafting Rails Appliations" and am using the enginex gem.
- I've replaced
/spec/dummy_appwith a git submodule pointing to a real Rails 3 app. - I'm having trouble loading the models from the engine (undefined symbol errors), as the real app's Gemfile doesn't point to the engine, and I also can't modify
config/application.rb, to require the engine (which is what the dummy app does, as explained on pages 15-16 of the book). - I'm including the engine's
libfolder into the load path$:inspec_helperand the paths are available. - Putting the
requireintospec_helper.rbdidn't solve the problem. - I'm wondering if there is an internal Rails API (or a clever monkey patch) to hook into the boot sequence of the real app and require the engine, without having to modify the real app's code (as it's in a submodule).
- Another issue I'm not fully sure about is that I have 2 Gemfiles (one in the engine and one in the app), and when the engine is active, they should both be used.
Thoughts?