When you’re a junior developer and you’re starting to test for the first time, the most difficult part is deciding on a testing library and getting it up and running. Once you pick a library and get it installed, it really isn’t difficult to start testing your entire application — most testing libraries are fairly easy to get the hang of.

RSpec is my go-to gem for testing a Ruby on Rails backend, and if you don’t have experience with it it can be difficult to get started. When I first started testing in Rails the biggest issue I had was learning how to install RSpec properly, so in this short tutorial I’ll show you how to install the RSpec library.

Before you begin installing RSpec, double-check that Ruby is installed by running the following command in our terminal:

$ ruby -v

This should output your version of Ruby:

ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin19]

If you see something similar to this printed out, you’re good to go. Otherwise you’ll want to check that Ruby is properly installed on your project.

Now you can install the RSpec gem on your project. Inside of your Gemfile add the following code:

#testing #ruby-on-rails #programming #ruby #backend

How to Install RSpec in Your Ruby on Rails Backend
1.30 GEEK