Just out of curiosity... in my previous post Rails3.1 engine: can't get SLIM or HAML to work in test/dummy app I asked where to tell Ruby to use some gem in my test/dummy
application.
The (obvious?) answer was to just put it into the Gemfile of my Engine. This works, but it makes me a bit uncomfortable because in Yehuda Katz' Post Clarifying the Roles of the .gemspec and Gemfile he mentions that...
...when developing a gem, the Gemfile "a gem’s Gemfile should contain the Rubygems source and a single gemspec line".
On the other hand, within my Engine's Gemfile (which was generated using Rails' rails plugin new my_engine
) there's:
# jquery-rails is used by the dummy application
gem "jquery-rails"
So this seems to be right. Update: no, it doesn't! Look at my answer below...
Still, somewhere else on StackOverflow I see the solution for this is said to simply require the needed gem in config/application.rb
, while https://stackoverflow.com/questions/5159607/rails-engine-gems-dependencies-how-to-load-them-into-the-application it's told to be put best into lib/<your_engine>/engine.rb file
.
And here's my thought: why doesn't the test/dummy
app simply automatically require all the Gems specified in the .gemspec
file? We even tell the gem, which gems to use for production and which for development mode by explicitly using add_dependency
and add_development_dependency
, so I don't see any reason why test/dummy
doesn't do this.
So here's the final question: Where exactly do I have to tell Ruby to use a gem in my test/dummy
app? I DON'T WANT TO FORCE RUBY TO USE THE GEM ALSO IN THE HOST APP.