RSpec is a testing tool for Ruby programmers. RSpec is a Behaviour-Driven Development (BDD) tool. Tests written in RSpec focus on the “behavior” of an application being tested. RSpec does not put emphasis on how the application works but instead on how it behaves, in other words, what the application actually does. RSpec is a DSL for writing tests. In other words, it tries to make tests as readable as possible. Not only that, it also produces output that reads like a story, or spec (“specification”), hence the name.
From the terminal, you can run the following command to install the rspec,
$ gem install rspec
Once the installation is completed now you can change the path to the project directory and run the rspec – -init it will initialize the rspec within the project.
$ mkdir rspec-tutorial
$ cd rspec-tutorial
$ rspec --init
It will create the following file under the project directory,
create .rspec
create spec/spec_helper.rb
That’s it the setup is completed. Now we can run the rspec test it will return the following output,
$ rspec
No examples found.
Finished in 0.00039 seconds (files took 0.12734 seconds to load)
0 examples, 0 failures
#rspec #ruby on rails #development