Install RSpec, Capybara, FactoryBot
Install rspec-rails
https://rubygems.org/gems/rspec-rails
Install this gem inside group :development, :test
NOTE: it must be gem 'rspec-rails' (not gem 'rspec' as it's github shows)
rails generate rspec:installGenerate a stub:
bundle binstubs rspec-coreEnable
--only-failuresby doing the following:In spec/spec_helper.rb, uncomment this line:
config.example_status_persistence_file_path = "spec/examples.txt"Create the file (leave it blank):
spec/examples.txtAdd
/spec/examples.txtto .gitignore
Install capybara
Note: If using Jumpstart, capybara is already included
https://rubygems.org/gems/capybara
Install this gem inside group :test
Install FactoryBot
Install FactoryBot:
Rspec Configuration
In spec/rails_helper.rb, inside of Rspec.configure do |config| ... add the following:
config.include Devise::Test::IntegrationHelpers, type: :feature
config.include FactoryBot::Syntax::Methods
Create Factories for user, account, account_user
This assumes you're using a fresh install of Jumpstart.
Create the following files:
spec/factories/account.rb:
spec/factories/user.rb:
spec/factories/account_user.rb:
Create an example spec
Create this in spec/features/example_spec.rb:
This example assumes you're using a fresh install of Jumpstart. You might need to adjust the content of this spec for it to work.
Last updated