This post is a memorandum of self-study.
After studying the railstutorial, I decided to rewrite the test from minitest to RSpec, which was the reason I tried to write this article.
This is my first post, but I hope this post is a hint for those who have read it.
$ rails new --skip-test --skip-bunlde
Skip the default minitest and bundle install.
Gemfile
group :development, :test do
gem 'rspec-rails'
gem 'spring-commands-rspec'
gem 'capybara'
gem 'factory_bot_rails'
gem 'faker'
gem 'selenium-webdriver'
gem 'database_cleaner'
end
$ bundle install --without production --path=vender/bundle
↑ Not to be confused with the gem of a system without a PC
$ rails g rspec:install
Running via Spring preloader in process 9045
create .rspec
create spec
create spec/spec_helper.rb
create spec/rails_helper.rb
RSpec execution time can be shortened by using spring. Use the gem'spring-commands-rspec' we added earlier for that. Create an RSpec stub file (./bin/rspec).
$ bundel exec spring binstub rspec
A bin/rspec file will be created and you can use spring by running RSpec.
*'Spring-commands-rspec': Required when executing bin/rspec commands. By adding a bin/command, RSpec can start an application called Spring, which is built into Rails, and speed up the process. RSpec itself can be used just by typing rspec.
config/environments/test.rb
config.active_support.deprecation = :stderr
↓ Change to the setting of where to output the deprecated report
config.active_support.deprecation = :silence
$ rails db:migrate RAILS_ENV=test
.rspec
--require spec_helper
--format documentation :Words that have passed the test will be displayed
--color
That's it for this time! How to write an article on Qiita It's quite unique I will do my best to post at least 2 articles a month! I'll do my best, 2021!
Recommended Posts