CheckOps home

Tools directory

R

CheckOps

RSpec

RSpec is the MIT-licensed behaviour-driven testing framework for Ruby, made up of rspec-core, rspec-expectations and rspec-mocks, and widely used with Rails via rspec-rails.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

RSpec is a testing framework for Ruby built around behaviour-driven development. Specs read as executable descriptions of how code should behave: describe Order do ... it "applies a discount" do ... end. It is the most widely used testing framework in the Ruby and Rails community alongside Minitest.

The project now lives in a mono repository containing the core gems. rspec-core provides the structure for writing examples and the rspec command with tools to choose which examples run and how output looks. rspec-expectations lets you express expected outcomes (expect(total).to eq(90)). rspec-mocks is a test-double framework with method stubs, fakes and message expectations on generated doubles and real objects. rspec-support holds shared helpers. Rails projects add rspec-rails, which provides model, request, system and other spec types.

RSpec’s DSL encourages small, focused examples with shared setup through let, before hooks, shared examples and contexts. Metadata and tags let you filter runs (rspec --tag ~slow), and features such as --only-failures, --next-failure, random ordering with seeds and --bisect help find order-dependent failures.

How it compares: Minitest ships with Ruby, is smaller and faster to load, and uses plain Ruby classes and assertions, which some teams prefer. RSpec offers a richer DSL, more expressive matchers and a large plugin ecosystem (for example shoulda-matchers, FactoryBot integration and Capybara for system specs). Many Rails teams choose RSpec for its readability; Rails itself defaults to Minitest.

In the quality loop, RSpec covers unit and integration tests for Ruby gems and Rails apps, and with Capybara it extends into browser-level system tests.

The source code is at rspec/rspec on GitHub under the MIT licence, with about 126 stars; the most recent commit was on 10 November 2026.

Configuration lives in .rspec and spec/spec_helper.rb (plus rails_helper.rb for Rails). Common settings include config.order = :random, config.example_status_persistence_file_path for the failure-tracking features, and config.disable_monkey_patching!, which keeps the global namespace clean by requiring RSpec.describe. Profiling with --profile lists the slowest examples, which helps keep suites fast as they grow. For parallelism, community tools such as parallel_tests split spec files across processes. RSpec’s long-standing documentation includes Cucumber-based feature files describing its own behaviour, which doubles as a reference for every matcher and option.

Development now happens in the rspec/rspec repository, the RSpec monorepo, which brings the project’s core gems together in one place for issues and pull requests.

Features

  1. Readable DSL: describe, context, it, let and subject make specs read like specifications.
  2. Matchers: eq, include, match, raise_error, change, have_attributes and composable custom matchers.
  3. Test doubles: double, instance_double (verifying doubles), allow(...).to receive and expect(...).to receive.
  4. Shared examples: Reuse behaviour specs across classes with shared_examples and it_behaves_like.
  5. Filtering and tags: Run by tag, file, line number or description; focus with fit and fdescribe.
  6. Random order and bisect: Run in random order with a seed and use --bisect to find minimal order-dependent failures.
  7. Failure workflows: --only-failures and --next-failure speed up fix-and-rerun cycles.
  8. Formatters: Progress, documentation, JSON and third-party formatters such as JUnit XML for CI.

Pros

  1. Expressive: Specs double as living documentation.
  2. Strong debugging tools: Random ordering with seeds, --bisect, --only-failures and --profile make suites easier to keep healthy as they grow.
  3. Rich ecosystem: rspec-rails, shoulda-matchers, Capybara and many extensions.
  4. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  5. Actively maintained: The repository had commits as recent as 10 November 2026.

Cons

  1. Heavier than Minitest: More DSL and slightly slower boot times on large apps.
  2. Overuse of let and nesting: Deeply nested contexts can make specs hard to follow.
  3. Mocking temptations: Partial doubles on real objects can produce brittle specs.
  4. Ruby only: Not applicable outside the Ruby ecosystem.

Add RSpec to a project and initialise it:

bundle add rspec --group "development, test"
bundle exec rspec --init

A spec with let, a context and a verifying double:

RSpec.describe Checkout do
  let(:gateway) { instance_double(PaymentGateway, charge: true) }
  subject(:checkout) { described_class.new(gateway: gateway) }

  context "with a valid card" do
    it "charges the total" do
      checkout.pay(total: 42_00)
      expect(gateway).to have_received(:charge).with(42_00)
    end
  end

  it "rejects negative totals" do
    expect { checkout.pay(total: -1) }.to raise_error(ArgumentError)
  end
end

For Rails, add rspec-rails and run rails generate rspec:install.

Practical tips:

  1. Keep random ordering on and record the seed in CI so order-dependent bugs surface early.
  2. Prefer instance_double over plain doubles so stubs fail if the real interface changes.
  3. Use --only-failures locally to iterate quickly after a red build.

Resources:

Pricing

RSpec is free and open source under the MIT licence.

  1. Ruby and Rails teams who value readable, specification-style tests.
  2. Teams practising BDD at the unit and integration level.
  3. Gem authors wanting expressive matchers and doubles.
  4. Teams with slow or order-dependent suites, who benefit from profiling, random ordering and bisect.
  5. Not a fit if you prefer the minimal, plain-Ruby style of Minitest.

Conclusion

RSpec remains the most expressive testing framework in Ruby, with a readable DSL, powerful matchers and verifying doubles.

Paired with FactoryBot, WebMock and Capybara, it covers most of a Ruby team’s testing needs from unit to system specs.

Compare

CheckOps pages that put RSpec next to related tools. There is no paid placement on these lists.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with RSpec side by side.