Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frodsan/mocoso
A minimalist stub & mock library
https://github.com/frodsan/mocoso
minimalist mock ruby stub
Last synced: 10 days ago
JSON representation
A minimalist stub & mock library
- Host: GitHub
- URL: https://github.com/frodsan/mocoso
- Owner: frodsan
- License: mit
- Created: 2013-10-01T02:09:09.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-05-02T22:32:16.000Z (over 8 years ago)
- Last Synced: 2024-10-10T15:38:09.223Z (about 1 month ago)
- Topics: minimalist, mock, ruby, stub
- Language: Ruby
- Homepage:
- Size: 58.6 KB
- Stars: 15
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rspec - mosoco - A minimalist stub & mock library. (Mocks)
README
Mocoso [![Build Status](https://travis-ci.org/frodsan/mocoso.svg)](https://travis-ci.org/frodsan/mocoso)
======Yet Another Simple Stub & Mock library. This is inspired by
[Minitest::Mock][minitest] and [Override][override].Description
-----------Mocoso meets the following criteria:
* Simplicity.
* Always restore stubbed methods to their original implementations.
* Doesn't allow to stub or mock undefined methods.
* Doesn't monkey-patch any class or object.
* Test-framework agnostic. No integration code.Installation
------------Add this line to your application's Gemfile:
```ruby
gem "mocoso"
```And then execute:
```
$ bundle
```Or install it yourself as:
```
$ gem install mocoso
```Usage
-----A quick example (uses [Cutest][cutest]):
```ruby
require "cutest"
require "mocoso"include Mocoso
test "mocking a class method" do
user = User.newexpect(User, :find, with: [1], return: user) do
assert_equal user, User.find(1)
endassert_equal nil, User.find(1)
endtest "stubbing an instance method" do
user = User.newstub(user, :valid?, true) do
assert user.valid?
endassert !user.valid?
end
```Check [Official Documentation][docs] for more details.
Contributing
------------Fork the project with:
```
$ git clone [email protected]:frodsan/mocoso.git
```To install dependencies, use:
```
$ bundle install
```To run the test suite, do:
```
$ rake test
```For bug reports and pull requests use [GitHub][issues].
License
-------Mocoso is released under the [MIT License][mit].
[docs]: http://rubydoc.info/github/harmoni/mocoso/
[cutest]: https://github.com/djanowski/cutest/
[issues]: https://github.com/frodsan/mocoso/issues
[minitest]: https://github.com/seattlerb/minitest/
[mit]: http://www.opensource.org/licenses/MIT
[override]: https://github.com/soveran/override/