A Ruby test double framework with a rich selection of double techniques and terse syntax.
RR is a test double framework for Ruby that provides a comprehensive set of techniques for creating mocks, stubs, spies, and proxies in tests. It solves the problem of isolating code under test by replacing dependencies with controlled doubles, enabling more reliable and maintainable test suites.
Ruby developers writing tests with RSpec, Test::Unit, MiniTest, or Minitest who need to create test doubles for their applications.
Developers choose RR for its rich selection of double techniques, terse syntax that reduces boilerplate, and seamless integration with multiple Ruby test frameworks without requiring complex configuration.
RR is a test double framework that features a rich selection of double techniques and a terse syntax. ⛺
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
RR supports stubs, mocks, spies, proxies, and class instance doubles, providing a wide range of techniques for isolating dependencies, as detailed in the whirlwind tour.
The syntax minimizes boilerplate, with concise calls like `stub(object).foo` and `mock.proxy(MyClass).new`, emphasizing readability and speed in test writing.
It works seamlessly with RSpec, Test::Unit, MiniTest, and Minitest, allowing developers to use the same double techniques across different testing environments without major configuration changes.
Unique among Ruby mocking libraries, proxies let you intercept existing methods to modify return values while preserving original behavior, useful for complex test scenarios as shown in the examples.
RR must be loaded after the test framework, requiring careful sequencing in test helpers; the README warns this can be error-prone, especially in Bundler or Rails projects.
Compatibility is officially listed only up to Ruby 3.0, missing newer versions like 3.1 and 3.2, which could force teams on modern stacks to seek alternatives.
Using RR with Test::Unit requires installing the separate test-unit-rr gem, adding an extra layer of maintenance and potential integration issues.