I'm wondering if there's a widely used pattern or solution for stubbing outbound HTTP requests to third-parties in Clojure integration tests (a la Ruby's webmock). I'd like to be able to stub requests at a high-level (for instance, in a setup function), without having to wrap each of my tests in something like (with-fake-http [] ...)
or having to resort to dependency injection.
Would this be a good use-case for a dynamic var? I suppose I could reach into the offending namespace in the setup step and set the side-effecting function to an innocuous anonymous function. However, this feels heavy-handed and I don't like the idea of changing my application code in order to accommodate my tests. (It also isn't much better than the solution mentioned above.)
Would it make sense to swap in a test-specific ns containing fake functions? Is there a clean way to do this from within my tests?