Skip to content
Browse files

Merge pull request #15 from carter-thaxton/patch-1

Extend sugar to support booleans
  • Loading branch information...
2 parents f34fc84 + eb72e1c commit b2a2674a6499434970bbd356473a0e100cc753d3 Marcin Bunsch committed Mar 23, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/jessie/sugar.js
View
5 lib/jessie/sugar.js
@@ -2,9 +2,11 @@
exports.sugar = function() {
var Sugar = {
should_be: function(compare) { expect(this).toEqual(compare); },
+ should_be_value: function(compare) { expect(this.valueOf()).toEqual(compare.valueOf()); },
should_be_a: function(object) { expect(this.constructor).toEqual(object) },
should_be_an_instance_of: function(object) { expect(true).toEqual(this instanceof(object)) },
should_not_be: function(compare) { expect(this).not.toEqual(compare); },
+ should_not_be_value: function(compare) { expect(this.valueOf()).not.toEqual(compare.valueOf()); },
should_match: function(compare) { expect(this).toMatch(compare); },
should_not_match: function(compare) { expect(this).not.toMatch(compare); },
should_have_been_called: function() { expect(this).toHaveBeenCalled(); },
@@ -18,14 +20,17 @@ exports.sugar = function() {
String.prototype.emitJasmine = function() { return this };
Number.prototype.emitJasmine = function() { return this };
Array.prototype.emitJasmine = function() { return this };
+ Boolean.prototype.emitJasmine = function() { return this };
String.prototype.should_be = Sugar.should_be
Number.prototype.should_be = Sugar.should_be
Array.prototype.should_be = Sugar.should_be
+ Boolean.prototype.should_be = Sugar.should_be_value
String.prototype.should_not_be = Sugar.should_not_be
Number.prototype.should_not_be = Sugar.should_not_be
Array.prototype.should_not_be = Sugar.should_not_be
+ Boolean.prototype.should_not_be = Sugar.should_not_be_value
String.prototype.should_be_a = Sugar.should_be_a
Number.prototype.should_be_a = Sugar.should_be_a

0 comments on commit b2a2674

Please sign in to comment.
Something went wrong with that request. Please try again.