A Gem used when writing unit test code in Rails.
Write gem'rspec-rails'. Be sure to be in the group: development,: test do ~ end </ font>
Gemfile
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails'
end
Make sure the current directory is the directory of the application that uses the test code in the terminal
bundle install
rails g rspec:install
This will generate a "spec directory" and a ".rspec file"
.rspec
--format documentation
Is added.
Introduce Gem as needed. This time, we are assuming a chat application, so we introduced it.
Gemfile
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails'
gem 'factory_bot_rails'
gem 'faker'
end
Described in the same group as before. </ font>
bundle install
Placed in public / images with the file name "test_image.png ".
-[x] rspec can be used only by doing "rails g rspec: install" as well as "bundle install". -[x] Describe in the group of group: development,: test do ~ end.
bundle install just got into Rails! Image to unzip with rails g rspec: install!
Detailed test code on another occasion.