RSpec is a BDD tool used to specify and test Ruby programs. It is used primarily to specify and test classes and methods, i.e. for unit testing.
The rspec gem is just a meta-gem which brings in the three parts of RSpec. Those three parts are also a way to structure this documentation.
rspec
command-line executable, the describe
, context
and it
methods, shared examples, etc. It is documented in the RSpec Core topic.expect
/to
expectation syntax and RSpec's built-in matchers. (It also provides the deprecated should
expectation syntax.) It is documented in the RSpec Expectations topic.double
, allow
, expect
, receive
, have_received
, etc. It is documented in the RSpec Mocks topic.There is also the rspec-rails gem, which extends RSpec with support for testing the types of classes used in Rails applications, and with support for writing feature specs (acceptance tests) which test the application from the user's point of view.
Official documentation for RSpec and rspec-rails is here: https://www.relishapp.com/rspec
This topic gives examples of how to expect test results in RSpec using expect .to
and the many built-in matchers.
This functionality is provided by the rspec-expectations gem.
This topic documents RSpec's support for test doubles (stubs, mocks, etc.). That support is provided by the rspec-mocks gem.