Rails: How to setup rspec on Rails
I'm a passionate software developer.
Add
rspecto the Gemfile;group :development, :test do gem 'rspec-rails' end
Install the dependencies
bundle installCheck if it was installed correctly
gem list rspecYou should see something like this

Check version

Install rspec
rails generate rspec:install
You should see something like this

Generate a rspec model
rails generate rspec:model ProductProductis a model. This is just an example.
Destroy a rspec model (Just in case you need it)
rails destroy rspec:model Product
Run a specific test on a single file
rspec spec/models/product_spec.rb:3In this example, the test starts in line 3.

You should see something like this
Run the tests for a single file
rspec spec/models/product_spec.rbYou should see something like this

Run all tests
rspec specYou should see something like this

Celebrate! It's working.

Conclusion
In this article, we learned how to setup Rspec on Rails.
Let me know if you need any additional help.




