Justin Searls
- 1y ·
-
Public·
-
mastodon.social
Finally thought of a name for the cool Mocktail API that overrides `YourClass․new` exactly once so that the test can instantiate its own dependencies instead of having to pass them in:
```
thing = Mocktail.of_next(Thing)
subject = ThingHaver․new
```
And receive the mock in its initializer:
```ruby
class ThingHaver
def initialize
@thing = Thing․new
end
end
```
It's not Dependency Injection, it's :sparkles: ✨ Dependency Inception ✨