Unit-Testing JavaScript

We are lucky enough to already have an interaction in our application that can be converted to JavaScript without much trouble and without being wildly implausible. We’ll go back to the project show page and convert those up and down buttons to JavaScript-enabled buttons that respond to clicks by rearranging the two rows in question and sending an Ajax notification of the change back to the server.

Setting Up Jasmine

We’ll be using Jasmine 2.0 as our primary JavaScript testing engine. Complete Jasmine documentation is at http://jasmine.github.io/2.0/introduction.html, and will cover any corners of the framework that we don’t get to here.

I like Jasmine because of its RSpec-like syntax, and it has historically been ...

Get Rails 4 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.