Client Unit Tests

Learn about testing clients, design decisions, and expectations adapter.

Clients in external service testing

VCR is set up. Now, let’s make the Twitter integration work. As it stands, the test fails because the user data is not in the view at all. The test suggests that the user email and the Twitter avatar should be in the view, so let’s add them to the view file.

Design decisions

We have a design decision to make about how the application should interact with Twitter. There are many options, ranging from calling the gem and service directly from the view to placing the interaction within the User class.

Our design here tends toward more objects and structure because we’re using this avatar to stand in for a more complex third-party integration. The classes’ set might feel like overkill, but we want to demonstrate what this is like with all the moving ...