Ask A Question


You’re not receiving notifications from this thread.

Testing HTTP Requests with Webmock Discussion

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.


I'm loving this series. Awesome work!


If anybody is looking for specs in rspec, I've created the same repo and added test cases in rspec =>

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.