Skip to content

Instantly share code, notes, and snippets.

@toddb
toddb / jasmine_extensions.js
Created April 11, 2012 20:02 — forked from esbie/jasmine_extensions.js
Jasmine spy syntactic sugar for dealing with success/error callbacks (aka jQuery.ajax)
/**
* An extension that always calls success when a spy is called.
*
* @example
* spyOn(foo, 'bar').andCallSuccessWith("baz");
* var options = {
* success: jasmine.createSpy();
* }
* foo.bar(options);
* expect(options.success).toBeCalledWith("baz");
@toddb
toddb / gist:1474205
Created December 13, 2011 22:27 — forked from mathieul/gist:966776
Require files using RequireJS before running Jasmine specs
/**
* @license Copyright (c) 2012, toddb GoneOpen Limited.
* Available via the MIT or new BSD license.
* based on https://gist.github.com/966776 (mathieul) and forked to https://gist.github.com/1474205
* jasmine.requirejs() returns a function that will load the file(s) required
* and will wait until it's done before proceeding with running specs.
* The function returned is intended to be passed to beforeEach() so the file(s)
* is(are) loaded before running each spec.
*