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 ✨

4
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Replies