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