RSpec test code execution

Introduction

I posted about how to install RSpec and how to write test code before, but I did not explain the actual test method, so I will look at how to execute the test I wrote this time.

[Previous post] After introducing RSpec, until you start writing unit test code for the model

I will not hesitate anymore! RSpec introduction flow

How to execute the written test code

After confirming that the current directory is the application being created, in the terminal

bundle exec rspec spec/models/file name

The file name is the file that actually describes the test code.

If the test goes well, there will be no errors and all exampl items (the part that describes what you want to check in Japanese) will turn green.

When stopped at binding.pry

% @user.valid?
#=>false
% @user.errors.full_messages

For user model unit test code Test if the result of @ user.errors.full_messages is included in the error message.

Recommended Posts

RSpec test code execution
[Rails] Test code using Rspec
[RSpec] How to write test code
Efficient test code
Introduce RSpec and write unit test code
Introduction to RSpec 1. Test, RSpec
[Test code learning / output]
[Rails] Test with RSpec
Test Nokogiri with Rspec.
RSpec unit test code creation procedure (login user creation Ver.)
Test Active Strage with RSpec
Memorandum (task: model test code)
Java test code method collection
Test GraphQL resolver with rspec
Implementation of unit test code
[Rails] About Rspec response test
About method matchers used in model unit test code (RSpec)
I'm writing test code using RSpec, but it doesn't work
Image upload using CarrierWave ~ Rspec test ~
Execution environment test after Java installation
Write test code in Spring Boot
Test with RSpec + Capybara + selenium + chromedriver
RSpec ~ Task model validation test creation
[RSpec on Rails] How to write test code for beginners by beginners
Understand code coverage with Rspec, the Ruby on Rails test framework
test
[Rails5] Rspec -Unit test when nesting-
test
About app testing RSpec (unit test)
test
Copy and paste test with RSpec
[RSpec] Unit test (using gem: factory_bot)
Let's unit test with [rails] Rspec!
[Rspec] Flow from introducing Rspec to writing unit test code for a model
[Rails] Unit test code for User model
[Ruby on Rails] View test with RSpec
CRuby code reading (3): rb_bug execution line output
[Ruby on Rails] Controller test with RSpec
What is the model test code testing
[Java] Flow from source code to execution
Write code that is difficult to test
[Ruby on Rails] Model test with RSpec
How to write an RSpec controller test
After introducing RSpec, until you start writing unit test code for your model