Adding development gem dependencies to a rails application.
It has been possible to specify gem dependencies for your application for a while. But sometimes when moving to another machine we would complain about there not being a development dependency option for config.gem as there is for gems. But we hadn’t actually given it any thought…
Today I had some weird test failures, which were related to not having test-spec 0.9 installed on my macbook. Most tests did pass because I did have an older version installed. So after a few minutes of thinking about it, I finally figured out the stupid simple solution. Simply define the dependencies in config/environments/test.rb!
# Development gems:
config.gem 'test-spec', :version => '0.9', :lib => 'test/spec'
config.gem 'mocha', :version => '0.9.3'
This one is probably obvious to some, but as far as I know it has never been actively promoted. And it’s just too easy to think of ;-)
Comments
Add your comment
In order to fight spam on this blog, posting comments from a browser without javascript is currently not supported.
Subscribe
bryanl about 5 hours later: (delete | show email)
This is a good tip. Seems so obvious, but I didn't think about it till reading this post. ¶
Chris Kampmeier 1 day later: (delete | show email)
We used to do this, but we eventually just moved everything back to environment.rb because of the hassle of having to do `rake gems:install` more than once to make sure you had all the latest development and test dependencies -- once for RAILS_ENV=test, once for RAILS_ENV=development, an so on.
These days we sometimes do this instead:
config.gem "ZenTest", :version => "3.11.0" unless RAILS_ENV == 'production'
That way our production servers don't end up requiring all the development/test gems, at least.
You can also pass :lib => false to require that a gem be installed but not attempt to load it, which comes in handy sometimes... ¶
software developer 325 days later: (delete)
Quite inspiring,
Very helpful when adding development gem dependencies to a rails application,
Thanks for bringing this up
http://www.geeks.ltd.uk/Services.html ¶