Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A mocking and stubbing library for Ruby
| Date | Stars |
|---|---|
| 2026-07-24 | 1285 |
| 2026-07-25 | 1285 |
| 2026-07-28 | 1285 |
| 2026-07-30 | 1285 |
| 2026-08-06 | 1285 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
## Mocha [](https://app.circleci.com/pipelines/github/freerange/mocha) [](http://badge.fury.io/rb/mocha)
### Description
* A Ruby library for [mocking](http://xunitpatterns.com/Mock%20Object.html) and [stubbing](http://xunitpatterns.com/Test%20Stub.html) - but deliberately not (yet) [faking](http://xunitpatterns.com/Fake%20Object.html) or [spying](http://xunitpatterns.com/Test%20Spy.html).
* A unified, simple and readable syntax for both full & partial mocking.
* Built-in support for Minitest and Test::Unit.
* Supported by many other test frameworks.
### Intended Usage
Mocha is intended to be used in unit tests for the [Mock Object](http://xunitpatterns.com/Mock%20Object.html) or [Test Stub](http://xunitpatterns.com/Test%20Stub.html) types of [Test Double](http://xunitpatterns.com/Test%20Double.html), not the [Fake Object](http://xunitpatterns.com/Fake%20Object.html) or [Test Spy](http://xunitpatterns.com/Test%20Spy.html) types. Although it would be possible to extend Mocha to allow the implementation of fakes and spies, we have chosen to keep it focused on mocks and stubs.
### Installation
#### Gem
Install the latest version of the gem with the following command...
$ gem install mocha
Note: If you are intending to use Mocha with Test::Unit or Minitest, you should only setup Mocha *after* loading the relevant test library...
##### Test::Unit
```ruby
require 'rubygems'
gem 'mocha'
require 'test/unit'
require 'mocha/test_unit'
```
##### Minitest
```ruby
require 'rubygems'
gem 'mocha'
require 'minitest/autorun'
require 'mocha/minitest'
```
#### Bundler
If you're using Bundler, include Mocha in the `Gemfile` and then setup Mocha later once you know the test library has been loaded...
##### Test::Unit
```ruby
# Gemfile
gem 'mocha'
# Elsewhere after Bundler has loaded gems e.g. after `require 'bundler/setup'`
require 'test/unit'
require 'mocha/test_unit'
```
##### Minitest
```ruby
# Gemfile
gem 'mocha'
# Elsewhere after Bundler has loaded gems e.g. after `require 'bundler/setup'`
require 'minitest/autorun'
require 'mocha/minitest'
```
##### RSpec
RSpec includes a mocha adapter. Just tell RSpec you want to mock with `:mocha`:
```ruby
# Gemfile in Rails app
gem 'mocha'
# Within `spec/spec_helper.rb`
RSpec.configure do |config|
config.mock_with :mocha
end
```
Note: There is no need to use a require statement to setup Mocha; RSpec does this itself.
##### Cucumber
```ruby
# In e.g. features/support/mocha.rb
require 'mocha/api'
World(Mocha::API)
Around do |scenario, block|
begin
mocha_setup
block.call
mocha_verify
ensure
mocha_teardown
end
end
```
#### Rails
If you're loading Mocha using Bundler within a Rails application, you should setup Mocha manually e.g. at the bottom of your `test_helper.rb`.
##### Minitest
Note that since Rails v4 (at least), `ActiveSupport::TestCase` has inherited from `Minitest::Test` or its earlier equivalents. Thus unless you are *explicitly* using Test::Unit, you are likely to be using Minitest.
```ruby
# Gemfile in Rails app
gem 'mocha'
# At bottom of test_helper.rb (or at least after `require 'rails/test_help'`)
require 'mocha/minitest'
```
##### Other Test Framework
Follow the instructions for the relevant test framework in the [Bundler](#bundler) section, but ensure that the relevant Mocha file (`mocha/minitest`, `mocha/test_unit`, or `mocha/api`) is required **after** the test framework has been loaded, e.g. at the bottom of `test_helper.rb` or `spec_helper.rb`, or at least after `rails/test_help` has been required.
#### Known Issues
* Prior to v1.15.0 (when support for Ruby v1.8 was dropped), stubbing an aliased class method where the original method is defined in a module that's used to `extend` the class doesn't work in Ruby v1.8. See `test/acceptance/stub_method_defined_on_module_and_aliased_Excerpt of 11,935 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:cab4543a5aa6cb90, topic:testing