Listing 3.1: A Gemfile for the sample app.

This includes rspec-rails in a development environment so that we have
access to RSpec-specific generators, and it includes it in test mode in
order to run the tests. We don’t have to install RSpec itself because it
is a dependency of rspec-rails and will thus be installed automatically.
We also include the Capybara gem, which allows us to simulate a user’s
interaction with the sample application using a natural English-like
syntax, together with Selenium, one of Capybara’s dependencies.1 As in
Chapter 2, we also must include the PostgreSQL and static assets gems in
production for deployment to Heroku:

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

Heroku recommends against using different databases in development and
production, but for the sample application it won’t make any difference,
and SQLite is much easier than PostgreSQL to install and configure.
Installing and configuring PostgreSQL on your local machine is left as
an exercise (Section 3.5).

To install and include the new gems, we run bundle install. As in
Section 1.4.1 and Chapter 2, we suppress the installation of production
gems using the option --without production:

$ bundle install --without production

In case you’ve previously installed a version of a gem (such as Rails
itself) other than the one specified by the Gemfile, it’s a good idea to
update the gems with bundle update to make sure the versions match, and
then run bundle install to make sure the Gemfile.lock file is fully
up-to-date:

$ bundle update
$ bundle install

Note that in the second line it’s unnecessary to include --without
production because it is a “remembered option”, which means that we
don’t have to include it in future invocations of Bundler. Instead, we
can write simply bundle install and production gems will be ignored
automatically.