Skip to content

Instantly share code, notes, and snippets.

@livecodelife
livecodelife / rails_engine_setup.md
Last active November 25, 2021 22:40
Rails Engine Setup with RSpec, Capybara, FactoryGirl, and DatabaseCleaner
  1. rails plugin new <project_name> -T -d postgresql --dummy-path=spec/dummy --skip-turbolinks --skip-spring --mountable
  • -T skips the creation of the test directory and the use of Test::Unit
  • --dummy-path=spec/dummy sets up your dummy app in a spec directory
  • --skip-turbolinks & --skip-spring creates a project that does not use turbolinks or spring
  • --mountable creates a "mountable" and namespace-isolated engine.
  1. In Gemfile:
  • gem 'rspec-rails' - user rspec in place of minitest (docs)
  • gem 'capybara' - act as a user navigating your site in tests (docs)
  • gem 'factory_girl_rails' - easily generate database objects without repetitive code in tests (docs)
  • gem 'database_cleaner' - clean your database between tests (docs)