Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do people group rspec under test and development in the Gemfile?

I'm generally clear on bundler Gemfile options, but I'm not sure why rspec (specifically, rspec-rails) should be in both test and development.

Here are my test groupings:

group :development, :test do   gem 'rspec-rails'   gem 'faker' end  group :test do   gem "factory_girl_rails"   gem "capybara"   gem 'guard-rspec'   gem 'rb-fsevent'   gem 'growl' end 

Does this look ok?

like image 291
Nathan Avatar asked May 02 '12 12:05

Nathan


People also ask

What are groups in Gemfile?

Since version 0.9, Bundler has had a feature called "groups". The purpose of this feature is to allow you to specify groups of dependencies which may be used in certain situations, but not in others. Specifying groups allows you to do two things. First, you can install the gems in your Gemfile, minus specific groups.

Why is RSpec used?

RSpec is a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications. Even though it has a very rich and powerful DSL (domain-specific language), at its core it is a simple tool which you can start using rather quickly.

How does RSpec subject work?

Summary: RSpec's subject is a special variable that refers to the object being tested. Expectations can be set on it implicitly, which supports one-line examples. It is clear to the reader in some idiomatic cases, but is otherwise hard to understand and should be avoided.

Is RSpec a framework?

RSpec is a computer domain-specific language (DSL) (particular application domain) testing tool written in the programming language Ruby to test Ruby code. It is a behavior-driven development (BDD) framework which is extensively used in production applications.


1 Answers

I am quoting the official documentation:

Add rspec-rails to the :test and :development groups in the Gemfile:

group :test, :development do        gem "rspec-rails", "~> 2.6"  end 

It needs to be in the :development group to expose generators and rake tasks without having to type RAILS_ENV=test.

like image 155
Amokrane Chentir Avatar answered Sep 30 '22 02:09

Amokrane Chentir