Client Unit Tests

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.

You 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.

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

Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.