Sha256: 4e990634f0165030a19edcdca28f940f288cdf9bea52aecf115fbb8203e35550

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

Fakes in Bogus are essentially lightweight objects that mimic the original object's interface.

Let's say that we have a `Library` class that is used to manage books and a `Student`, who can interact with the `Library` in some way.

In order to test the `Student` in isolation, we need to replace the `Library`, with some test double. Typically, you would do that by creating an anonymous stub/mock object and stubbing the required methods on it.

Using those stubs, you specify the desired interface of the library object.

The problems with that approach start when you change the `Library` class. For example, you could rename the `#checkout` method to `#checkout_book`. If you used the standard approach, where your stubs are not connected in any way to the real implementation, your tests will keep happily passing, even though the collaborator interface just changed.

Bogus saves you from this problem, because your fakes have the exact same interface as the real collaborators, so whenever you change the collaborator, but not the tested object, you will get an exception in your tests.

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bogus-0.1.7 features/fakes/readme.md
bogus-0.1.6 features/fakes/readme.md
bogus-0.1.5 features/fakes/readme.md
bogus-0.1.4 features/fakes/readme.md
bogus-0.1.3 features/fakes/readme.md
bogus-0.1.2 features/fakes/readme.md
bogus-0.1.1 features/fakes/readme.md
bogus-0.1.0 features/fakes/readme.md
bogus-0.0.4 features/fakes/readme.md
bogus-0.0.3 features/fakes/readme.md
bogus-0.0.3.rc.2 features/fakes/readme.md
bogus-0.0.3.rc.1 features/fakes/readme.md