$ rails -v
If you don't, install rails
$ gem install rails
$ rails new <project-name> -T --database=postgresql
-T
prevents minitest from being installed, we will use rspec instead
You should see something similar to this depending on your local ruby and rails versions
ruby '3.0.1'
gem 'rails', '~> 6.0.3'
# Git ignore database configuration
/config/database.yml
group :development, :test do
gem 'rspec-rails', '~> 3.8'
end
$ bundle
$ rails generate rspec:install
This will generate .rspec
, spec/rails_helper.rb
, spec/spec_helper.rb
Require rails_helper
in the .rspec
file. This way you don't have to manually add it to every single test file.
This is what your .rspec
file should look like:
--require spec_helper
--require rails_helper
$ rake db:setup
You can now start creating your models, controllers, views, etc