Testing HTTP Requests with Webmock Discussion
Discussion for
Testing HTTP Requests with Webmock
Great episode! Instead of testing private methods directly, I suggest to define a FakeApiClient
class that extends ApplicationClient
with some dummy methods. This allows testing public methods. Plus, it allows you to remove the BASE_URI
constant from ApplicationClient
and define it in FakeApiClient
.
I think is a nice idea. On the other hand I like how he does here is easy to understand.
You'll want to do that for your actual integrations, for sure.
These are just some tests to make sure we've implemented the generic HTTP calls correctly. That way our real API clients don't have to worry about testing the underlying HTTP methods, they can focus on everything else.