Keploy logo
Ruby logo

Keploy as a Ruby testing framework

Keploy tests Ruby applications by recording real HTTP and ActiveRecord traffic from a running app, then replaying it as assertions. There are no WebMock stubs to register, no VCR cassettes to re-record by hand, and no test database to load a schema into.

Generate Ruby tests free
keploy record -c "bundle exec rails server"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Ruby team

Any Ruby app, unchanged

Keploy runs the app through rails server, rackup, or Puma. Rails, Sinatra, Hanami, and plain Rack apps all record the same way because capture happens at the socket.

  • Ruby 3.0 and above
  • Rails, Sinatra, Hanami, Rack
  • Puma, Unicorn, or Passenger
  • No spec_helper changes
The problem

Why Ruby integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing Ruby: by hand, with RSpec + WebMock, or with Keploy

WebMock stubs and VCR cassettes are both frozen the moment they are written. Keploy records the real exchange, so re-recording refreshes every mock at once instead of one cassette at a time.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Ruby vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
order_controller_spec.rb
hand-written
# Hand-written: doubles and payloads all by hand.
require 'rails_helper'
 
class FakeOrderRepository
def find(id)
{ id: id, amount_minor: 4200, state: 'NEW' }
end
end
 
class FakePayments
def authorize(_token)
{ 'status' => 'AUTHORIZED' }
end
end
 
RSpec.describe OrderController do
it 'confirms an authorized order' do
controller = described_class.new(FakeOrderRepository.new, FakePayments.new)
 
response = controller.confirm('ord_1', 'tok_123')
 
expect(response.status).to eq(200)
expect(response.body[:state]).to eq('CONFIRMED')
end
end

Two double classes exist only for this file, and both hard-code a shape nothing verifies against the real Postgres rows or Stripe response.

RSpec + WebMock1–2 hours
order_controller_webmock_spec.rb
tool-assisted
# RSpec + WebMock + FactoryBot.
require 'rails_helper'
require 'webmock/rspec'
 
RSpec.describe OrderController do
before do
create(:order, id: 'ord_1', amount_minor: 4200, state: 'NEW')
 
# A literal that will not change when Stripe does.
stub_request(:post, %r{payment_intents/tok_123/confirm})
.to_return(
status: 200,
body: { status: 'AUTHORIZED' }.to_json,
headers: { 'Content-Type' => 'application/json' },
)
end
 
it 'confirms an authorized order' do
post "/orders/ord_1/confirm", params: { payment_token: 'tok_123' }
 
expect(response).to have_http_status(:ok)
expect(json_body['state']).to eq('CONFIRMED')
end
end

Readable and fully offline — and the Stripe body is a hand-typed literal that no longer resembles the real response the day their API changes.

With Keploy~5 minutes
test-1.yaml
auto-generated
# Recorded with: keploy record -c 'bundle exec rails server'
# No WebMock stub, no cassette, no schema load.
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
req:
method: POST
url: /orders/ord_1/confirm
body: '{"payment_token":"tok_123"}'
resp:
status_code: 200
body:
id: "ord_1"
state: "CONFIRMED"
amount_minor: 4200
confirmed_at: "2026-09-02T11:04:18Z"
noise:
- body.confirmed_at
mocks:
- kind: Postgres
operation: 'SELECT "orders".* FROM "orders" WHERE "orders"."id" = $1 LIMIT 1'
- kind: Http
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm
status: 200

The mock is the SQL ActiveRecord actually generated, so a scope change shows up as a real diff instead of passing against a factory-built record.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

Ruby testing tools, compared

The options a team on Ruby actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your Ruby app once, replay it forever

Keploy sits below your Ruby process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a Ruby service and captures the dependency calls it makes.

An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

What Keploy mocks for Ruby, with zero config

6 of the 7 dependencies a typical Ruby service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.

Quick start

Your first Ruby test suite in under five minutes

Every command below runs against your existing Ruby service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "bundle exec rails server"
  3. 3Exercise the paths you care about

    Drive the app with curl or your frontend. Every request becomes a test case with its ActiveRecord queries and HTTP calls captured alongside.

    curl -X POST localhost:3000/orders/ord_1/confirm -H 'Content-Type: application/json' -d '{"payment_token":"tok_123"}'
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "bundle exec rails server" --delay 12

Ready to try it on your own Ruby service?

Ecosystem

Works with the rest of your Ruby stack

Keploy records at the network layer, so framework and driver choices inside your Ruby app do not change how it captures traffic.

FAQ

Ruby testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.