Inc1982
Inc1982

Reputation: 1975

When should I use development vs testing group in gemfile for testing gems?

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!

Upvotes: 12

Views: 1594

Answers (1)

Gazler
Gazler

Reputation: 84180

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.

Upvotes: 10

Related Questions