# freerange/mocha

A mocking and stubbing library for Ruby

Repository: https://github.com/freerange/mocha
Canonical: https://ross.abutalabs.com/products/freerange-mocha
Homepage: https://mocha.jamesmead.org
Language: Ruby
License: NOASSERTION
License Family: other
Topics: ruby, minitest, test-unit, mock, stub, testing
Last push: 2026-07-13T18:36:38+00:00

## Health v2 (maintenance only)
Score: 74/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 92, release rhythm 35, longevity 100
- inputs: {"age_days": 6542, "days_push": 51, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases, no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1284, forks 158 (observed 2026-08-28T04:04:14.638208+00:00)

## What it is
Mocha is a Ruby library for mocking and stubbing in unit tests, providing a unified syntax for full and partial mocking of test doubles. It integrates with Minitest, Test::Unit, RSpec, and Cucumber.

## Use cases
- stub methods on Ruby objects in unit tests
- create mock objects with expectations for unit testing
- mock with Minitest
- use mocha adapter with RSpec
- partially mock existing Ruby objects
- verify method invocation counts in tests

## When to choose
- you need mocks or stubs in Ruby tests with Minitest, Test::Unit, or RSpec
- you want a simple, readable mocking syntax
- you need partial mocking of real objects

## When to avoid
- you need test spies or fake objects, which Mocha deliberately does not support
- you are not writing Ruby
- you prefer RSpec's built-in double/expect syntax

## Facets
- artifact type: library
- maturity: stable
- function: testing, mocking
- domain: testing, developer-tools
- platform: ruby
- tags: test-double, stubbing, minitest, test-unit, rspec

## Member repositories
- freerange/mocha (main) score 74

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:14.638208+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:56:44.152259+00:00, confidence not recorded.
  - readme: https://github.com/freerange/mocha (fetched 2026-08-28T04:04:14.638208+00:00, sha 5bbae0ebd2a5)
  - homepage: https://mocha.jamesmead.org (fetched 2026-08-29T12:12:27.276476+00:00, sha cfaec7998439)
  - site_page: https://mocha.jamesmead.org/Mocha/Mock.html (fetched 2026-08-29T12:12:27.279388+00:00, sha 8f8e805c4868)
  - site_page: https://mocha.jamesmead.org/Mocha/Configuration.html (fetched 2026-08-29T12:12:27.281351+00:00, sha 7f3985eac478)
- Data as of 2026-08-30T08:39:29.467469+00:00.
