Testing a controller that makes outside api calls

This is how I decide. If the API module that talks to the external API (this would be TwiterClient in your example) is part of my codebase, I write tests for it and simulate the interactions with the external API using Bypass. If the module is part of a library, then it’s (hopefully) already tested and so I don’t write any tests for it. When testing a consumer of the API module, I mock the API module.

This seems pretty straightforward to me, but I’d be interested to hear what other people on this thread have to say, maybe they have a different opinion.

When writing tests using Bypass, I can confirm that @dimitarvp’s suggestions of dumping response from the real API to generate fixtures is indeed a very good one! I’m glad that others are also doing it :slight_smile: