RSpec clone Home

A small RSpec clone based on Fix testing tools for Ruby.

Warning ⚠️

I'd like to avoid confusion in the Ruby community by emphasizing that the gem of this project is not rspec but r_spec.

The r_spec gem is a minimalist and personal reimplementation of the popular RSpec framework. My reimplementation is therefore independent of the original RSpec project.

On the job

For the purpose of the DSL reimplementation, I have kept the same RSpec module name, and following the Ruby gems naming convention, I called its gem r_spec.

However, to go further and explicitly indicate that this reimplementation is a clone, I have grouped all the code in a RSpec::Clone submodule within its r_spec-clone gem.

Why did I redid that?

An urge to simplify the RSpec DSL and reduce the complexity of the code that implements it, and nothing better to do during a stay in Tokyo.


Add this line to your application's Gemfile:

gem "r_spec"

And then execute:

bundle install

Or install it yourself as:

gem install r_spec


All the code is centralized in the RSpec::Clone module, whose source code is versioned at

To download the latest updates of the r_spec-clone gem, this command can be executed:

bundle update r_spec

Or update it yourself as:

gem update r_spec


Let's imagine a string_hello_world_spec.rb file that contains this code:

# frozen_string_literal: false

require "r_spec"

app = "Hello, World!"

RSpec.describe String do
  subject do

  before do
    subject.gsub!("World", friend)

  context "when Alice is greeted" do
    let(:friend) { "Alice" }

    it { eq "Hello, Alice!" }

  context "when Bob is greeted" do
    let(:friend) { "Bob" }

    it { eq "Hello, Bob!" }

We can run it with Ruby:

ruby string_hello_world_spec.rb

The report of the execution should be:

Success: expected to eq "Hello, Alice!".
Success: expected to eq "Hello, Bob!".


RSpec uses Semantic Versioning 2.0.0


The gem is available as open source under the terms of the MIT License.