O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

We have a design decision to make about how our application should interact with Twitter. We have 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required