For some reason this hasn't hit home, and I'm wondering if someone could help explain..
I noticed when installing 'guard' gem, that they recommend placing a lot of the gems in the 'development group' in the gemfile, such as 'growl' and 'rb-notifu': https://github.com/guard/guard..
Also Ryan Bates seems in one screen cast seems to put many of these in 'development' & 'testing': http://railscasts.com/episodes/264-guard?view=asciicast
But in another puts it all in 'testing': http://railscasts.com/episodes/275-how-i-test
It'd be nice to understand this so I don't have to reference tutorials all the time. Thanks!
We see there are two groups (:development and :test) added to our Gemfile. This helps us in installing gems only for specific environments. Gems installed in the development group will only be available in the development environment and the same goes for the rest.
There are several ways to specify gem versions: Use a specific version: gem "name-of-gem", "1.0" . You can find specific versions on Rubygems.org (provided that's the source you”re using) by searching for your gem and looking at the “Versions” listed. Use a version operator: gem "name-of-gem", ">1.0" .
You use :require => false when you want the gem to be installed but not "required". So in the example you gave: gem 'whenever', :require => false when someone runs bundle install the whenever gem would be installed as with gem install whenever .
The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” which contains a packaged Ruby application or library. Gems can be used to extend or modify functionality in Ruby applications.
Gems that you run from the development environment should be present in both the development and test groups. You run things like rspec
cucumber
and guard
from development and they run in the test environment, you need them in development to run the rake tasks and the executables.
Gems that only run while in test mode, such as capybara
email_spec
and launchy
can exist only in the test group and still function correctly.
I hope this helps clear things up.
As a general rule, gems that are executable need to be in both. Also, if you are unsure, put it in both groups too.
Edit
If the gem you are using has generators (rails generate
), it needs to be present in both test and development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With