Wednesday, July 13, 2022

How to install Rspec

Add rspec-rails to both the :development and :test groups of your app’s Gemfile:

# Run against this stable release
group :development, :test do
  gem 'rspec-rails', '~> 6.0.0'
end

# Download and install
$ bundle install

# Generate boilerplate configuration files
# (check the comments in each generated file for more information)
$ rails generate rspec:install
      create  .rspec
      create  spec
      create  spec/spec_helper.rb
      create  spec/rails_helper.rb

$ rails generate respec:model user
# Running spec
$ bundle exec rspec spec/models (Run all spec files)
$ bundle exec rspec spec/models/user_spec.rb (Run a single spec file)

$ rails generate rspec:system users
# Running spec
$ bundle exec rspec spec/system/users_spec.rb

Source: rspec-rails

Tip: ※$ rails generate

No comments:

Post a Comment