Skip to content

Instantly share code, notes, and snippets.

@esbie
esbie / jasmine_matcher_extensions.js
Created November 22, 2011 03:43
Jasmine spy syntactic sugar for ignoring event arguments
/**
* Matcher that mimics toHaveBeenCalledWith, except it ignores the first argument (and isn't robust enough to handle more than one call)
*
* @example
*
*/
jasmine.Matchers.prototype.toHaveBeenTriggeredWith = function() {
var expectedArgs = jasmine.util.argsToArray(arguments);
if (!jasmine.isSpy(this.actual)) {
@esbie
esbie / jasmine_extensions.js
Created October 30, 2011 06:18
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");
@esbie
esbie / oblit
Created June 29, 2011 01:04
Cleaning up Git branches is tedious
#!/usr/bin/env ruby
if ARGV.size != 1
puts "what branch?"
exit 1
end
`git branch -D #{ARGV[0]}`
`git push origin :#{ARGV[0]}`