1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
# Bogus
Bogus aims to make your unit tests more reliable by ensuring that you don't stub or mock methods that don't actually exist in the mocked objects.
[](http://travis-ci.org/psyho/bogus)
[](https://codeclimate.com/github/psyho/bogus)
[](https://coveralls.io/r/psyho/bogus?branch=master)
[](http://badge.fury.io/rb/bogus)
[](https://gemnasium.com/psyho/bogus)
[](http://githalytics.com/psyho/bogus)
## Example
```ruby
class PostRepository
def store(title)
# save a new post in the database
end
end
class PostAdder < Struct.new(:post_repository)
def add(title)
post = post_repository.store(title)
# do some stuff with the post
end
end
require 'bogus/rspec'
describe PostAdder do
fake(:post_repository)
it "stores the post" do
post_adder = PostAdder.new(post_repository)
post_adder.add("Bogus is safe!")
expect(post_repository).to have_received.store("Bogus is safe!")
end
end
```
## Features
* [Safe Stubbing][safe-stubbing] - Bogus does not allow you to stub methods that don't exist or don't match the stubbed signature.
* [Fakes][fakes] - test doubles that have the same interface as the doubled class.
* [Support for ActiveRecord models][ar-support] - Bogus comes with support for active record fields out of the box.
* [Global fake configuration][global-configuration] - Decouple your fakes from class names and define default return values in one place.
* [Contract tests][contract-tests] - a unique feature of Bogus, which reduces the need for integrated tests to a minimum by ensuring that the things you stub match how the object really behaves.
## Documentation
[You can find more detailed (and executable) documentation on Relish.][docs]
## License
MIT. See the [LICENSE file][license].
## Authors
* [Adam Pohorecki](http://github.com/psyho)
* [Paweł Pierzchała](http://github.com/wrozka)
* [Piotr Szotkowski](https://github.com/chastell)
* [Marek Nowak](https://github.com/yundt)
[docs]: http://www.relishapp.com/bogus/bogus/docs
[safe-stubbing]: https://www.relishapp.com/bogus/bogus/docs/safe-stubbing
[fakes]: https://www.relishapp.com/bogus/bogus/docs/fakes
[ar-support]: https://www.relishapp.com/bogus/bogus/docs/configuration/fake-ar-attributes
[global-configuration]: https://www.relishapp.com/bogus/bogus/docs/fakes/global-fake-configuration
[contract-tests]: https://www.relishapp.com/bogus/bogus/docs/contract-tests
[license]: features/license.md
|