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

Testing Ajax Calls

Our JavaScript up/down functionality has one more piece: we need to notify the server that the up or down has taken place. That involves making an Ajax call to the server. We probably want to notify the user of success or failure (or at least of failure).

Typically we stub Ajax calls to the server because they’re slow and because they might otherwise require server-side setup to return useful data. We could use plain Jasmine spies for this, or Jasmine’s Ajax framework. Instead I’m going to bring in a different tool that has a slightly higher-level API for managing Ajax.

The tool is called Sinon.[26] It is actually a framework-independent mock-object library, but we’re not going to discuss its generic library, just its fake ...

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