rails new <project_name> -d postgresql --skip-test-unit --skip-turbolinks --skip-spring
-d postgresql
sets up the project to use PostgreSQL--skip-test-unit
skips the creation of the test directory--skip-turbolinks
&--skip-spring
creates a project that does not use turbolinks or spring
- In the Gemfile:
- inside of
group :development, :test
:gem 'rspec-rails'
bundle
rails g rspec:install
gem 'capybara
- inside of
rails_helper.rb
:require 'capybara/rails'
- inside of
gem 'launchy
- for running save_and_open_pagegem 'shoulda-matchers'
- easy model testing- inside of
rails_helper.rb
:
Shoulda::Matchers.configure do |config| config.integrate do |with| with.test_framework :rspec with.library :rails end end
- inside of
gem 'unicorn'
- slightly faster web servergem 'rails_12factor', group: :production
- If publishing on Herokugem 'database_cleaner'
(test only)- (optional)
gem 'factory_girl_rails'
(test only)touch spec/support/factory_girl.rb
:
RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods config.before(:suite) do begin DatabaseCleaner.start FactoryGirl.link ensure DatabaseCleaner.clean end end end
- In
rails_helper.rb
uncomment `Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } touch spec/support/factories.rb
FactoryGirl.define do <factories for each model go here> end
- (if not using FactoryGirl)
gem 'figaro'
bundle exec figaro install