Skip to content

Instantly share code, notes, and snippets.

@codespore
Last active April 29, 2020 21:49
Show Gist options
  • Save codespore/a4d07f430bd601d6a3e555be419cef51 to your computer and use it in GitHub Desktop.
Save codespore/a4d07f430bd601d6a3e555be419cef51 to your computer and use it in GitHub Desktop.
Guide to setup RSpec 4 in your Rails 6 application
# Spin up a new rails application and make sure your database and schema is created
rails new example-app -T -d postgresql
# Add and install the following gems to your Gemfile
group :development, :test do
...
gem 'rspec-rails'
gem 'capybara'
gem 'selenium-webdriver'
end
# Run Rspec generator
rails g rspec:install
# Require the rspec rails and capybara at the top of the rails_helper.rb file
require 'rspec/rails'
require 'capybara/rspec'
# Create your spec files under the respective spec folders
spec/controllers/posts_controller.rb
spec/system/user_create_post.rb
# Run your spec files and watch them fail
rspec spec/system/user_create_post.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment