From b92187507b250cca749e02730120fd6f5adc5842 Mon Sep 17 00:00:00 2001 From: Jasmine Hegman Date: Thu, 25 Jul 2013 18:08:39 -0700 Subject: [PATCH 01/77] Added normalization so that normalized events can utilize toHandleWith Added unit tests around them --- lib/jasmine-jquery.js | 3 ++- spec/suites/jasmine-jquery-spec.js | 34 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index fec162c0..e2b75331 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -517,7 +517,8 @@ jasmine.JQuery.matchersClass = {} // tests the existence of a specific event binding + handler toHandleWith: function(eventName, eventHandler) { - var stack = $._data(this.actual.get(0), "events")[eventName] + var normalizedEventName = eventName.split('.')[0]; + var stack = $._data(this.actual.get(0), "events")[normalizedEventName] for (var i = 0; i < stack.length; i++) { if (stack[i].handler == eventHandler) return true } diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 24f06d92..4b76a757 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -1311,6 +1311,40 @@ describe("jQuery matchers", function() { $(object).bind('click', handler) expect($(object)).toHandleWith('click', handler) }) + + it("should pass if the namespaced event is bound with the given handler", function() { + var handler = function(){ }; // noop + $('#clickme').bind("click.namespaced", handler) + expect($('#clickme')).toHandleWith("click.namespaced", handler) + expect($('#clickme').get(0)).toHandleWith("click.namespaced", handler) + }) + + it('should pass if the namespaced event is not bound with the given handler', function() { + var handler = function(){ } + $('#clickme').bind("click", handler) + + var aDifferentHandler = function(){ } + expect($('#clickme')).not.toHandleWith("click.namespaced", aDifferentHandler) + expect($('#clickme').get(0)).not.toHandleWith("click.namespaced", aDifferentHandler) + }) + + it('should pass if the namespaced event is not bound at all', function() { + expect($('#clickme')).not.toHandle("click.namespaced") + expect($('#clickme').get(0)).not.toHandle("click.namespaced") + }) + + it("should pass if the namespaced event on window is bound with the given handler", function(){ + var handler = function(){ } + $(window).bind("resize.namespaced", handler) + expect($(window)).toHandleWith("resize.namespaced", handler) + }) + + it("should pass if the namespaced event on any object is bound with the given handler", function(){ + var object = new function(){ }; // noop + var handler = function(){ } + $(object).bind('click.namespaced', handler) + expect($(object)).toHandleWith('click.namespaced', handler) + }) }) }) From e95a4aa3d72c4ebca9de84e89e8e93180e47d5fe Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Fri, 26 Jul 2013 21:04:16 -0500 Subject: [PATCH 02/77] v1.5.6 --- bower.json | 2 +- lib/jasmine-jquery.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 43c777c2..aa54efe5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.5", + "version": "1.5.6", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index e2b75331..df1b7b34 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. - Version 1.5.5 + Version 1.5.6 /~https://github.com/velesin/jasmine-jquery From 33b5ad36f2ff17b70399b9d3b918b6cbabb375dd Mon Sep 17 00:00:00 2001 From: Alex Kwiatkowski and Rick Reilly Date: Wed, 31 Jul 2013 11:09:11 -0400 Subject: [PATCH 03/77] Refactor jasmine.Fixtures.createContainer_ to be more concise jQuery.fn.html() can optionally take a node or string. This means there is no need to use string concatenation when building the container --- lib/jasmine-jquery.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index df1b7b34..062ee0d0 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -151,13 +151,9 @@ jasmine.Fixtures.prototype.sandbox = function(attributes) { } jasmine.Fixtures.prototype.createContainer_ = function(html) { - var container - if(html instanceof $) { - container = $('
') - container.html(html) - } else { - container = '
' + html + '
' - } + var container = $('
') + .attr('id', this.containerId) + .html(html); $(document.body).append(container) } From 63277384dfb0d820418f9835e80df68952b6352e Mon Sep 17 00:00:00 2001 From: Alex Kwiatkowski and Rick Reilly Date: Wed, 31 Jul 2013 11:45:45 -0400 Subject: [PATCH 04/77] Fixture.set() & setFixture() return the fixture container --- lib/jasmine-jquery.js | 5 +++-- spec/suites/jasmine-jquery-spec.js | 32 +++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 062ee0d0..a9d5aa53 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -43,7 +43,7 @@ var appendLoadFixtures = function() { } var setFixtures = function(html) { - jasmine.getFixtures().proxyCallTo_('set', arguments) + return jasmine.getFixtures().proxyCallTo_('set', arguments) } var appendSetFixtures = function() { @@ -106,7 +106,7 @@ jasmine.Fixtures = function() { jasmine.Fixtures.prototype.set = function(html) { this.cleanUp() - this.createContainer_(html) + return this.createContainer_(html) } jasmine.Fixtures.prototype.appendSet= function(html) { @@ -155,6 +155,7 @@ jasmine.Fixtures.prototype.createContainer_ = function(html) { .attr('id', this.containerId) .html(html); $(document.body).append(container) + return container } jasmine.Fixtures.prototype.addToContainer_ = function(html){ diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 4b76a757..a2c9b4e6 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -229,16 +229,17 @@ describe("jasmine.Fixtures", function() { expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - it("should have shortcut global method setFixtures", function() { - setFixtures(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) - }) - describe("when fixture container does not exist", function() { it("should automatically create fixtures container and append it to DOM", function() { jasmine.getFixtures().set(html) expect(fixturesContainer().size()).toEqual(1) }) + + it("should return the fixture container", function() { + var container = jasmine.getFixtures().set(html) + expect(container).toExist() + expect(container[0]).toEqual(fixturesContainer()[0]) + }) }) describe("when fixture container exists", function() { @@ -250,9 +251,30 @@ describe("jasmine.Fixtures", function() { jasmine.getFixtures().set(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) + + it("should return the fixture container", function(){ + var container = jasmine.getFixtures().set(html) + expect(container).toExist() + expect(container[0]).toEqual(fixturesContainer()[0]) + }) }) }) + describe("setFixtures", function() { + var html = '
some HTML
' + + it("should be a shortcut global method", function() { + setFixtures(html) + expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + }) + + it("should return the fixture container", function() { + var container = setFixtures(html) + expect(container).toExist() + expect(container[0]).toEqual(fixturesContainer()[0]) + }) + }); + describe("appendSet",function(){ var html = '
some HTML
' it("should insert HTML into container", function() { From ce0d7ae1266262968e0fea45910a6fc85d92b605 Mon Sep 17 00:00:00 2001 From: Cody Sehl Date: Thu, 1 Aug 2013 21:47:03 -0600 Subject: [PATCH 05/77] Adding support for jQuery object equality --- lib/jasmine-jquery.js | 12 ++++++++++ spec/suites/jasmine-jquery-spec.js | 37 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index df1b7b34..dc05b77d 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -655,6 +655,18 @@ beforeEach(function() { return jasmine.JQuery.events.wasStopped(selector, eventName) } }) + jasmine.getEnv().addEqualityTester(function(a, b) { + if(a instanceof jQuery && b instanceof jQuery) { + if(a.size() != b.size()) { + return jasmine.undefined; + } + else if(a.is(b)) { + return true; + } + } + return jasmine.undefined; + + }) }) afterEach(function() { diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 4b76a757..496da8e6 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -1667,4 +1667,41 @@ describe("jasmine.JSONFixtures using real AJAX call", function() { }) }) +describe("jasmine.Env.equalityTesters_", function() { + describe("jQuery object tester", function() { + beforeEach(function() { + setFixtures(sandbox()) + }) + + it("should equate the same element with different selectors", function() { + expect($('#sandbox')).toEqual($('div#sandbox')) + }) + + it("should equate jquery objects that match a set of elements", function() { + $('#sandbox').append($('
')) + $('#sandbox').append($('
')) + expect($('#sandbox div')).toEqual($('div#sandbox div')) + }) + it("should not equate jquery objects that match a set of elements where one has an extra", function() { + $('#sandbox').append($('
')) + $('#sandbox').append($('
')) + $('#sandbox').append($('')) + expect($('#sandbox div')).not.toEqual($('div#sandbox div, div#sandbox span')) + }) + + it("should not equate jquery objects that match a set of elements of the same type where the tag types are the same, but they are not the same DOM elements", function() { + $('#sandbox').append($('
')) + $('#sandbox').append($('')) + $('#sandbox').append($('
')) + $('#sandbox').append($('')) + expect($('.one')).not.toEqual($('.two').first()) + }) + + it("should not equate jquery objects that match a set of elements of the same type where one is missing a single element", function() { + $('#sandbox').append($('
')) + $('#sandbox').append($('
')) + expect($('#sandbox div')).not.toEqual($('div#sandbox div').first()) + }) + }) +}) \ No newline at end of file From 7a99076cf11b634764ba0c30281b372f09742d2b Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Fri, 2 Aug 2013 15:07:26 -0500 Subject: [PATCH 06/77] v1.5.7 --- bower.json | 2 +- lib/jasmine-jquery.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index aa54efe5..71aae435 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.6", + "version": "1.5.7", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index dc05b77d..6e1784ab 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. - Version 1.5.6 + Version 1.5.7 /~https://github.com/velesin/jasmine-jquery From 7f01294ee0d5e8a58f20e66df3928ab1478584dc Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Fri, 2 Aug 2013 15:16:56 -0500 Subject: [PATCH 07/77] v1.5.8 --- bower.json | 2 +- lib/jasmine-jquery.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 71aae435..602ed530 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.7", + "version": "1.5.8", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index af04c0d6..c04edfb7 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. - Version 1.5.7 + Version 1.5.8 /~https://github.com/velesin/jasmine-jquery From 3269b0c77d0c888260e864c92cf6cb97f3a5647d Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Fri, 2 Aug 2013 15:22:52 -0500 Subject: [PATCH 08/77] Document #138 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index a3ee69d7..8e042ae9 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,11 @@ All of above methods have matching global short cuts: - `setFixtures(html)` - `appendSetFixtures(html)` +``` javascript +var fixture = setFixture('
foo
') +var post = fixture.find('.post') +``` + Also, a helper method for creating HTML elements for your tests is provided: - `sandbox([{attributeName: value[, attributeName: value, ...]}])` From 03ece9b3abfa75462e1151b1add56bf2f0171ffb Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 21 Aug 2013 21:24:22 -0500 Subject: [PATCH 09/77] Remove merged semicolons --- lib/jasmine-jquery.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index c04edfb7..9cad20cd 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -153,7 +153,7 @@ jasmine.Fixtures.prototype.sandbox = function(attributes) { jasmine.Fixtures.prototype.createContainer_ = function(html) { var container = $('
') .attr('id', this.containerId) - .html(html); + .html(html) $(document.body).append(container) return container } @@ -338,13 +338,13 @@ jasmine.JQuery.matchersClass = {} }, args: function(selector, eventName) { - var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]; + var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] if (!actualArgs) { - throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."; + throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." } - return actualArgs; + return actualArgs }, wasTriggered: function(selector, eventName) { @@ -352,22 +352,22 @@ jasmine.JQuery.matchersClass = {} }, wasTriggeredWith: function(selector, eventName, expectedArgs, env) { - var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1); + var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1) if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { - actualArgs = actualArgs[0]; + actualArgs = actualArgs[0] } - return env.equals_(expectedArgs, actualArgs); + return env.equals_(expectedArgs, actualArgs) }, wasPrevented: function(selector, eventName) { var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], - e = args ? args[0] : undefined; + e = args ? args[0] : undefined return e && e.isDefaultPrevented() }, wasStopped: function(selector, eventName) { var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], - e = args ? args[0] : undefined; + e = args ? args[0] : undefined return e && e.isPropagationStopped() }, @@ -376,7 +376,7 @@ jasmine.JQuery.matchersClass = {} data.handlers = [] } } -}(jasmine.JQuery) +}(jasmine.JQuery); !function(){ var jQueryMatchers = { @@ -455,7 +455,7 @@ jasmine.JQuery.matchersClass = {} if (text && $.isFunction(text.test)) { return text.test(trimmedText) } else { - return trimmedText.indexOf(text) != -1; + return trimmedText.indexOf(text) != -1 } }, @@ -514,7 +514,7 @@ jasmine.JQuery.matchersClass = {} // tests the existence of a specific event binding + handler toHandleWith: function(eventName, eventHandler) { - var normalizedEventName = eventName.split('.')[0]; + var normalizedEventName = eventName.split('.')[0] var stack = $._data(this.actual.get(0), "events")[normalizedEventName] for (var i = 0; i < stack.length; i++) { if (stack[i].handler == eventHandler) return true @@ -586,10 +586,10 @@ beforeEach(function() { toHaveBeenTriggeredOnAndWith: function() { var selector = arguments[0], expectedArgs = arguments[1], - wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual); + wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) this.message = function() { if (wasTriggered) { - var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1]; + var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] return [ "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) @@ -601,7 +601,7 @@ beforeEach(function() { ] } } - return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env); + return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) } }) this.addMatchers({ @@ -655,19 +655,19 @@ beforeEach(function() { jasmine.getEnv().addEqualityTester(function(a, b) { if(a instanceof jQuery && b instanceof jQuery) { if(a.size() != b.size()) { - return jasmine.undefined; + return jasmine.undefined } else if(a.is(b)) { - return true; + return true } } - return jasmine.undefined; + return jasmine.undefined }) -}) +}); afterEach(function() { jasmine.getFixtures().cleanUp() jasmine.getStyleFixtures().cleanUp() jasmine.JQuery.events.cleanUp() -}) +}); From 9385875313807b9adba3b2f7779ce7c3a0a2326a Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 17:53:41 -0500 Subject: [PATCH 10/77] Add package.json --- package.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 00000000..6830fdef --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "jasmine-jquery" + , "description": "jQuery matchers and fixture loader for Jasmine framework" + , "version": "1.5.8" + , "keywords": ["jasmine", "jquery"] + , "homepage": "http://github.com/velesin/jasmine-jquery" + , "author": "Travis Jeffery" + , "scripts": { "test": "grunt test" } + , "repository": { + "type": "git" + , "url": "/~https://github.com/velesin/jasmine-jquery.git" + } + , "bugs": { + "http://github.com/velesin/jasmine-jquery/issues" + } + , "license": "MIT" +} From f7b9a850be1b539156381d176a48629b175dfd17 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 20:57:28 -0500 Subject: [PATCH 11/77] Add jshint config --- .jshintrc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..a5e6e4aa --- /dev/null +++ b/.jshintrc @@ -0,0 +1,16 @@ +{ + "validthis" : true + , "multistr" : true + , "laxcomma" : true + , "laxbreak" : true + , "browser" : true + , "eqeqeq" : false + , "eqnull" : true + , "debug" : true + , "devel" : true + , "curly" : false + , "boss" : true + , "expr" : true + , "asi" : true + , "supernew" : true +} From c5979b2a5fd0683b2fa7e9f24b9e663c3c202ced Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 20:57:35 -0500 Subject: [PATCH 12/77] Fix specs for jshint --- spec/suites/jasmine-jquery-spec.js | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 0442009f..455c1f25 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -874,26 +874,26 @@ describe("jQuery matchers", function() { describe("toHaveLength", function() { it("should pass on an object with more than zero items", function() { - var $three = $('
').add('').add("
")
-    	expect($three.length).toBe(3)
-    	expect($three).toHaveLength(3)
+      var $three = $('
').add('').add("
")
+      expect($three.length).toBe(3)
+      expect($three).toHaveLength(3)
     })
     it("should pass negated on an object with more than zero items", function() {
-    	var $three = $('
').add('').add("
")
-    	expect($three.length).toBe(3)
-    	expect($three).not.toHaveLength(2)
+      var $three = $('
').add('').add("
")
+      expect($three.length).toBe(3)
+      expect($three).not.toHaveLength(2)
     })
 
     it("should pass on an object with zero items", function() {
-    	var $zero = $()
-    	expect($zero.length).toBe(0)
-    	expect($zero).toHaveLength(0)
+      var $zero = $()
+      expect($zero.length).toBe(0)
+      expect($zero).toHaveLength(0)
     })
 
     it("should pass negated on an object with zero items", function() {
-    	var $zero = $()
-    	expect($zero.length).not.toBe(1)
-    	expect($zero).not.toHaveLength(1)
+      var $zero = $()
+      expect($zero.length).not.toBe(1)
+      expect($zero).not.toHaveLength(1)
     })
   })
 
@@ -1242,7 +1242,7 @@ describe("jQuery matchers", function() {
     var handler
     beforeEach(function() {
       setFixtures(sandbox().html('Click Me Other Link'))
-      handler = function(){ }; // noop
+      handler = function(){}
     })
 
     it("should handle events on the window object", function(){
@@ -1289,7 +1289,7 @@ describe("jQuery matchers", function() {
     })
 
     it('should handle event on any object', function(){
-      var object = new function(){ }; // noop
+      var object = new function(){}
       $(object).bind('click', function(){})
       expect($(object)).toHandle('click')
     })
@@ -1301,17 +1301,17 @@ describe("jQuery matchers", function() {
     })
 
     it('should pass if the event is bound with the given handler', function() {
-      var handler = function(){ }; // noop
+      var handler = function(){}
       $('#clickme').bind("click", handler)
       expect($('#clickme')).toHandleWith("click", handler)
       expect($('#clickme').get(0)).toHandleWith("click", handler)
     })
 
     it('should pass if the event is not bound with the given handler', function() {
-      var handler = function(){ }
+      var handler = function(){}
       $('#clickme').bind("click", handler)
 
-      var aDifferentHandler = function(){ }
+      var aDifferentHandler = function(){}
       expect($('#clickme')).not.toHandleWith("click", aDifferentHandler)
       expect($('#clickme').get(0)).not.toHandleWith("click", aDifferentHandler)
     })
@@ -1322,30 +1322,30 @@ describe("jQuery matchers", function() {
     })
 
     it("should pass if the event on window is bound with the given handler", function(){
-      var handler = function(){ }
+      var handler = function(){}
       $(window).bind("resize", handler)
       expect($(window)).toHandleWith("resize", handler)
     })
 
     it("should pass if the event on any object is bound with the given handler", function(){
-      var object = new function(){ }; // noop
-      var handler = function(){ }
+      var object = new function(){}
+      var handler = function(){}
       $(object).bind('click', handler)
       expect($(object)).toHandleWith('click', handler)
     })
 
     it("should pass if the namespaced event is bound with the given handler", function() {
-      var handler = function(){ }; // noop
+      var handler = function(){}
       $('#clickme').bind("click.namespaced", handler)
       expect($('#clickme')).toHandleWith("click.namespaced", handler)
       expect($('#clickme').get(0)).toHandleWith("click.namespaced", handler)
     })
 
     it('should pass if the namespaced event is not bound with the given handler', function() {
-      var handler = function(){ }
+      var handler = function(){}
       $('#clickme').bind("click", handler)
 
-      var aDifferentHandler = function(){ }
+      var aDifferentHandler = function(){}
       expect($('#clickme')).not.toHandleWith("click.namespaced", aDifferentHandler)
       expect($('#clickme').get(0)).not.toHandleWith("click.namespaced", aDifferentHandler)
     })
@@ -1356,14 +1356,14 @@ describe("jQuery matchers", function() {
     })
 
     it("should pass if the namespaced event on window is bound with the given handler", function(){
-      var handler = function(){ }
+      var handler = function(){}
       $(window).bind("resize.namespaced", handler)
       expect($(window)).toHandleWith("resize.namespaced", handler)
     })
 
     it("should pass if the namespaced event on any object is bound with the given handler", function(){
-      var object = new function(){ }; // noop
-      var handler = function(){ }
+      var object = new function(){}
+      var handler = function(){}
       $(object).bind('click.namespaced', handler)
       expect($(object)).toHandleWith('click.namespaced', handler)
     })

From 1783e05f438acb29d3576e48429bf6eca7452095 Mon Sep 17 00:00:00 2001
From: Travis Jeffery 
Date: Sat, 31 Aug 2013 20:58:42 -0500
Subject: [PATCH 13/77] .gitignore

---
 .gitignore | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/.gitignore b/.gitignore
index 2d961f6b..ec18efd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,18 @@
 lib/external
 .idea
+lib-cov
+.grunt
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+npm-debug.log
+node_modules
\ No newline at end of file

From 00d78ad87ece7f269fd8b3d3d58015d01169bba4 Mon Sep 17 00:00:00 2001
From: Travis Jeffery 
Date: Sat, 31 Aug 2013 21:00:19 -0500
Subject: [PATCH 14/77] Add gruntfile

---
 Gruntfile.js | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Gruntfile.js

diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 00000000..3fc7ba9c
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,33 @@
+/* jshint node: true */
+
+module.exports = function(grunt) {
+  "use strict";
+
+  grunt.initConfig({
+      pkg: grunt.file.readJSON('package.json')
+    , jshint: {
+        all: [
+            "Gruntfile.js"
+          , "lib/*.js"
+          , "spec/**/*.js"
+        ]
+      , options: {
+          jshintrc: '.jshintrc'
+        },
+      }
+    , jasmine: {
+        src: "lib/*.js"
+      , options: {
+          specs: "spec/**/*.js"
+        , vendor: "vendor/**/*.js"
+        , keepRunner: true
+      }
+    }
+  })
+
+  grunt.loadNpmTasks('grunt-contrib-jshint')
+  grunt.loadNpmTasks('grunt-contrib-jasmine')
+
+  grunt.registerTask('test', ['jshint', 'jasmine'])
+  grunt.registerTask('default', ['test'])
+};

From f4b983a46f6b13dc95abce0b351a5457d02ff60b Mon Sep 17 00:00:00 2001
From: Travis Jeffery 
Date: Sat, 31 Aug 2013 21:00:29 -0500
Subject: [PATCH 15/77] Add package.json

---
 package.json | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index 6830fdef..05c9a3d8 100644
--- a/package.json
+++ b/package.json
@@ -4,14 +4,23 @@
   , "version": "1.5.8"
   , "keywords": ["jasmine", "jquery"]
   , "homepage": "http://github.com/velesin/jasmine-jquery"
-  , "author": "Travis Jeffery"
+  , "author": {
+      "name": "Travis Jeffery"
+    , "email": "tj@travisjeffery.com"
+    , "url": "travisjeffery.com"
+  }
   , "scripts": { "test": "grunt test" }
   , "repository": {
       "type": "git"
     , "url": "/~https://github.com/velesin/jasmine-jquery.git"
   }
   , "bugs": {
-     "http://github.com/velesin/jasmine-jquery/issues"
+     "url": "http://github.com/velesin/jasmine-jquery/issues"
   }
   , "license": "MIT"
+  , "devDependencies": {
+      "grunt": "~0.4.1"
+    , "grunt-contrib-jshint": "~0.6.0"
+    , "grunt-contrib-jasmine": "~0.4.0"
+  }
 }

From 23edf15abeec85b45141cafd428c526790846926 Mon Sep 17 00:00:00 2001
From: Travis Jeffery 
Date: Sat, 31 Aug 2013 21:01:31 -0500
Subject: [PATCH 16/77] Remove unnessary files

---
 SpecRunner.html                |   52 -
 vendor/jasmine/jasmine-html.js |  681 ---------
 vendor/jasmine/jasmine.css     |   82 -
 vendor/jasmine/jasmine.js      | 2600 --------------------------------
 4 files changed, 3415 deletions(-)
 delete mode 100644 SpecRunner.html
 delete mode 100644 vendor/jasmine/jasmine-html.js
 delete mode 100644 vendor/jasmine/jasmine.css
 delete mode 100644 vendor/jasmine/jasmine.js

diff --git a/SpecRunner.html b/SpecRunner.html
deleted file mode 100644
index 83103783..00000000
--- a/SpecRunner.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-  Jasmine Spec Runner
-
-  
-
-  
-
-  
-  
-
-  
-
-  
-  
-
-  
-
-
-
-
-
-
diff --git a/vendor/jasmine/jasmine-html.js b/vendor/jasmine/jasmine-html.js
deleted file mode 100644
index 543d5696..00000000
--- a/vendor/jasmine/jasmine-html.js
+++ /dev/null
@@ -1,681 +0,0 @@
-jasmine.HtmlReporterHelpers = {};
-
-jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
-  var el = document.createElement(type);
-
-  for (var i = 2; i < arguments.length; i++) {
-    var child = arguments[i];
-
-    if (typeof child === 'string') {
-      el.appendChild(document.createTextNode(child));
-    } else {
-      if (child) {
-        el.appendChild(child);
-      }
-    }
-  }
-
-  for (var attr in attrs) {
-    if (attr == "className") {
-      el[attr] = attrs[attr];
-    } else {
-      el.setAttribute(attr, attrs[attr]);
-    }
-  }
-
-  return el;
-};
-
-jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
-  var results = child.results();
-  var status = results.passed() ? 'passed' : 'failed';
-  if (results.skipped) {
-    status = 'skipped';
-  }
-
-  return status;
-};
-
-jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
-  var parentDiv = this.dom.summary;
-  var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
-  var parent = child[parentSuite];
-
-  if (parent) {
-    if (typeof this.views.suites[parent.id] == 'undefined') {
-      this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
-    }
-    parentDiv = this.views.suites[parent.id].element;
-  }
-
-  parentDiv.appendChild(childElement);
-};
-
-
-jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
-  for(var fn in jasmine.HtmlReporterHelpers) {
-    ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
-  }
-};
-
-jasmine.HtmlReporter = function(_doc) {
-  var self = this;
-  var doc = _doc || window.document;
-
-  var reporterView;
-
-  var dom = {};
-
-  // Jasmine Reporter Public Interface
-  self.logRunningSpecs = false;
-
-  self.reportRunnerStarting = function(runner) {
-    var specs = runner.specs() || [];
-
-    if (specs.length == 0) {
-      return;
-    }
-
-    createReporterDom(runner.env.versionString());
-    doc.body.appendChild(dom.reporter);
-    setExceptionHandling();
-
-    reporterView = new jasmine.HtmlReporter.ReporterView(dom);
-    reporterView.addSpecs(specs, self.specFilter);
-  };
-
-  self.reportRunnerResults = function(runner) {
-    reporterView && reporterView.complete();
-  };
-
-  self.reportSuiteResults = function(suite) {
-    reporterView.suiteComplete(suite);
-  };
-
-  self.reportSpecStarting = function(spec) {
-    if (self.logRunningSpecs) {
-      self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
-    }
-  };
-
-  self.reportSpecResults = function(spec) {
-    reporterView.specComplete(spec);
-  };
-
-  self.log = function() {
-    var console = jasmine.getGlobal().console;
-    if (console && console.log) {
-      if (console.log.apply) {
-        console.log.apply(console, arguments);
-      } else {
-        console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
-      }
-    }
-  };
-
-  self.specFilter = function(spec) {
-    if (!focusedSpecName()) {
-      return true;
-    }
-
-    return spec.getFullName().indexOf(focusedSpecName()) === 0;
-  };
-
-  return self;
-
-  function focusedSpecName() {
-    var specName;
-
-    (function memoizeFocusedSpec() {
-      if (specName) {
-        return;
-      }
-
-      var paramMap = [];
-      var params = jasmine.HtmlReporter.parameters(doc);
-
-      for (var i = 0; i < params.length; i++) {
-        var p = params[i].split('=');
-        paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
-      }
-
-      specName = paramMap.spec;
-    })();
-
-    return specName;
-  }
-
-  function createReporterDom(version) {
-    dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
-      dom.banner = self.createDom('div', { className: 'banner' },
-        self.createDom('span', { className: 'title' }, "Jasmine "),
-        self.createDom('span', { className: 'version' }, version)),
-
-      dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
-      dom.alert = self.createDom('div', {className: 'alert'},
-        self.createDom('span', { className: 'exceptions' },
-          self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
-          self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
-      dom.results = self.createDom('div', {className: 'results'},
-        dom.summary = self.createDom('div', { className: 'summary' }),
-        dom.details = self.createDom('div', { id: 'details' }))
-    );
-  }
-
-  function noTryCatch() {
-    return window.location.search.match(/catch=false/);
-  }
-
-  function searchWithCatch() {
-    var params = jasmine.HtmlReporter.parameters(window.document);
-    var removed = false;
-    var i = 0;
-
-    while (!removed && i < params.length) {
-      if (params[i].match(/catch=/)) {
-        params.splice(i, 1);
-        removed = true;
-      }
-      i++;
-    }
-    if (jasmine.CATCH_EXCEPTIONS) {
-      params.push("catch=false");
-    }
-
-    return params.join("&");
-  }
-
-  function setExceptionHandling() {
-    var chxCatch = document.getElementById('no_try_catch');
-
-    if (noTryCatch()) {
-      chxCatch.setAttribute('checked', true);
-      jasmine.CATCH_EXCEPTIONS = false;
-    }
-    chxCatch.onclick = function() {
-      window.location.search = searchWithCatch();
-    };
-  }
-};
-jasmine.HtmlReporter.parameters = function(doc) {
-  var paramStr = doc.location.search.substring(1);
-  var params = [];
-
-  if (paramStr.length > 0) {
-    params = paramStr.split('&');
-  }
-  return params;
-}
-jasmine.HtmlReporter.sectionLink = function(sectionName) {
-  var link = '?';
-  var params = [];
-
-  if (sectionName) {
-    params.push('spec=' + encodeURIComponent(sectionName));
-  }
-  if (!jasmine.CATCH_EXCEPTIONS) {
-    params.push("catch=false");
-  }
-  if (params.length > 0) {
-    link += params.join("&");
-  }
-
-  return link;
-};
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
-jasmine.HtmlReporter.ReporterView = function(dom) {
-  this.startedAt = new Date();
-  this.runningSpecCount = 0;
-  this.completeSpecCount = 0;
-  this.passedCount = 0;
-  this.failedCount = 0;
-  this.skippedCount = 0;
-
-  this.createResultsMenu = function() {
-    this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
-      this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
-      ' | ',
-      this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
-
-    this.summaryMenuItem.onclick = function() {
-      dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
-    };
-
-    this.detailsMenuItem.onclick = function() {
-      showDetails();
-    };
-  };
-
-  this.addSpecs = function(specs, specFilter) {
-    this.totalSpecCount = specs.length;
-
-    this.views = {
-      specs: {},
-      suites: {}
-    };
-
-    for (var i = 0; i < specs.length; i++) {
-      var spec = specs[i];
-      this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
-      if (specFilter(spec)) {
-        this.runningSpecCount++;
-      }
-    }
-  };
-
-  this.specComplete = function(spec) {
-    this.completeSpecCount++;
-
-    if (isUndefined(this.views.specs[spec.id])) {
-      this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
-    }
-
-    var specView = this.views.specs[spec.id];
-
-    switch (specView.status()) {
-      case 'passed':
-        this.passedCount++;
-        break;
-
-      case 'failed':
-        this.failedCount++;
-        break;
-
-      case 'skipped':
-        this.skippedCount++;
-        break;
-    }
-
-    specView.refresh();
-    this.refresh();
-  };
-
-  this.suiteComplete = function(suite) {
-    var suiteView = this.views.suites[suite.id];
-    if (isUndefined(suiteView)) {
-      return;
-    }
-    suiteView.refresh();
-  };
-
-  this.refresh = function() {
-
-    if (isUndefined(this.resultsMenu)) {
-      this.createResultsMenu();
-    }
-
-    // currently running UI
-    if (isUndefined(this.runningAlert)) {
-      this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
-      dom.alert.appendChild(this.runningAlert);
-    }
-    this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
-
-    // skipped specs UI
-    if (isUndefined(this.skippedAlert)) {
-      this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
-    }
-
-    this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
-
-    if (this.skippedCount === 1 && isDefined(dom.alert)) {
-      dom.alert.appendChild(this.skippedAlert);
-    }
-
-    // passing specs UI
-    if (isUndefined(this.passedAlert)) {
-      this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
-    }
-    this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
-
-    // failing specs UI
-    if (isUndefined(this.failedAlert)) {
-      this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
-    }
-    this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
-
-    if (this.failedCount === 1 && isDefined(dom.alert)) {
-      dom.alert.appendChild(this.failedAlert);
-      dom.alert.appendChild(this.resultsMenu);
-    }
-
-    // summary info
-    this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
-    this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
-  };
-
-  this.complete = function() {
-    dom.alert.removeChild(this.runningAlert);
-
-    this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
-
-    if (this.failedCount === 0) {
-      dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
-    } else {
-      showDetails();
-    }
-
-    dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
-  };
-
-  return this;
-
-  function showDetails() {
-    if (dom.reporter.className.search(/showDetails/) === -1) {
-      dom.reporter.className += " showDetails";
-    }
-  }
-
-  function isUndefined(obj) {
-    return typeof obj === 'undefined';
-  }
-
-  function isDefined(obj) {
-    return !isUndefined(obj);
-  }
-
-  function specPluralizedFor(count) {
-    var str = count + " spec";
-    if (count > 1) {
-      str += "s"
-    }
-    return str;
-  }
-
-};
-
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
-
-
-jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
-  this.spec = spec;
-  this.dom = dom;
-  this.views = views;
-
-  this.symbol = this.createDom('li', { className: 'pending' });
-  this.dom.symbolSummary.appendChild(this.symbol);
-
-  this.summary = this.createDom('div', { className: 'specSummary' },
-    this.createDom('a', {
-      className: 'description',
-      href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
-      title: this.spec.getFullName()
-    }, this.spec.description)
-  );
-
-  this.detail = this.createDom('div', { className: 'specDetail' },
-      this.createDom('a', {
-        className: 'description',
-        href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
-        title: this.spec.getFullName()
-      }, this.spec.getFullName())
-  );
-};
-
-jasmine.HtmlReporter.SpecView.prototype.status = function() {
-  return this.getSpecStatus(this.spec);
-};
-
-jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
-  this.symbol.className = this.status();
-
-  switch (this.status()) {
-    case 'skipped':
-      break;
-
-    case 'passed':
-      this.appendSummaryToSuiteDiv();
-      break;
-
-    case 'failed':
-      this.appendSummaryToSuiteDiv();
-      this.appendFailureDetail();
-      break;
-  }
-};
-
-jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
-  this.summary.className += ' ' + this.status();
-  this.appendToSummary(this.spec, this.summary);
-};
-
-jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
-  this.detail.className += ' ' + this.status();
-
-  var resultItems = this.spec.results().getItems();
-  var messagesDiv = this.createDom('div', { className: 'messages' });
-
-  for (var i = 0; i < resultItems.length; i++) {
-    var result = resultItems[i];
-
-    if (result.type == 'log') {
-      messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
-    } else if (result.type == 'expect' && result.passed && !result.passed()) {
-      messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
-
-      if (result.trace.stack) {
-        messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
-      }
-    }
-  }
-
-  if (messagesDiv.childNodes.length > 0) {
-    this.detail.appendChild(messagesDiv);
-    this.dom.details.appendChild(this.detail);
-  }
-};
-
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
-  this.suite = suite;
-  this.dom = dom;
-  this.views = views;
-
-  this.element = this.createDom('div', { className: 'suite' },
-    this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
-  );
-
-  this.appendToSummary(this.suite, this.element);
-};
-
-jasmine.HtmlReporter.SuiteView.prototype.status = function() {
-  return this.getSpecStatus(this.suite);
-};
-
-jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
-  this.element.className += " " + this.status();
-};
-
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
-
-/* @deprecated Use jasmine.HtmlReporter instead
- */
-jasmine.TrivialReporter = function(doc) {
-  this.document = doc || document;
-  this.suiteDivs = {};
-  this.logRunningSpecs = false;
-};
-
-jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
-  var el = document.createElement(type);
-
-  for (var i = 2; i < arguments.length; i++) {
-    var child = arguments[i];
-
-    if (typeof child === 'string') {
-      el.appendChild(document.createTextNode(child));
-    } else {
-      if (child) { el.appendChild(child); }
-    }
-  }
-
-  for (var attr in attrs) {
-    if (attr == "className") {
-      el[attr] = attrs[attr];
-    } else {
-      el.setAttribute(attr, attrs[attr]);
-    }
-  }
-
-  return el;
-};
-
-jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
-  var showPassed, showSkipped;
-
-  this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
-      this.createDom('div', { className: 'banner' },
-        this.createDom('div', { className: 'logo' },
-            this.createDom('span', { className: 'title' }, "Jasmine"),
-            this.createDom('span', { className: 'version' }, runner.env.versionString())),
-        this.createDom('div', { className: 'options' },
-            "Show ",
-            showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
-            this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
-            showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
-            this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
-            )
-          ),
-
-      this.runnerDiv = this.createDom('div', { className: 'runner running' },
-          this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
-          this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
-          this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
-      );
-
-  this.document.body.appendChild(this.outerDiv);
-
-  var suites = runner.suites();
-  for (var i = 0; i < suites.length; i++) {
-    var suite = suites[i];
-    var suiteDiv = this.createDom('div', { className: 'suite' },
-        this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
-        this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
-    this.suiteDivs[suite.id] = suiteDiv;
-    var parentDiv = this.outerDiv;
-    if (suite.parentSuite) {
-      parentDiv = this.suiteDivs[suite.parentSuite.id];
-    }
-    parentDiv.appendChild(suiteDiv);
-  }
-
-  this.startedAt = new Date();
-
-  var self = this;
-  showPassed.onclick = function(evt) {
-    if (showPassed.checked) {
-      self.outerDiv.className += ' show-passed';
-    } else {
-      self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
-    }
-  };
-
-  showSkipped.onclick = function(evt) {
-    if (showSkipped.checked) {
-      self.outerDiv.className += ' show-skipped';
-    } else {
-      self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
-    }
-  };
-};
-
-jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
-  var results = runner.results();
-  var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
-  this.runnerDiv.setAttribute("class", className);
-  //do it twice for IE
-  this.runnerDiv.setAttribute("className", className);
-  var specs = runner.specs();
-  var specCount = 0;
-  for (var i = 0; i < specs.length; i++) {
-    if (this.specFilter(specs[i])) {
-      specCount++;
-    }
-  }
-  var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
-  message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
-  this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
-
-  this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
-};
-
-jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
-  var results = suite.results();
-  var status = results.passed() ? 'passed' : 'failed';
-  if (results.totalCount === 0) { // todo: change this to check results.skipped
-    status = 'skipped';
-  }
-  this.suiteDivs[suite.id].className += " " + status;
-};
-
-jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
-  if (this.logRunningSpecs) {
-    this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
-  }
-};
-
-jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
-  var results = spec.results();
-  var status = results.passed() ? 'passed' : 'failed';
-  if (results.skipped) {
-    status = 'skipped';
-  }
-  var specDiv = this.createDom('div', { className: 'spec '  + status },
-      this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
-      this.createDom('a', {
-        className: 'description',
-        href: '?spec=' + encodeURIComponent(spec.getFullName()),
-        title: spec.getFullName()
-      }, spec.description));
-
-
-  var resultItems = results.getItems();
-  var messagesDiv = this.createDom('div', { className: 'messages' });
-  for (var i = 0; i < resultItems.length; i++) {
-    var result = resultItems[i];
-
-    if (result.type == 'log') {
-      messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
-    } else if (result.type == 'expect' && result.passed && !result.passed()) {
-      messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
-
-      if (result.trace.stack) {
-        messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
-      }
-    }
-  }
-
-  if (messagesDiv.childNodes.length > 0) {
-    specDiv.appendChild(messagesDiv);
-  }
-
-  this.suiteDivs[spec.suite.id].appendChild(specDiv);
-};
-
-jasmine.TrivialReporter.prototype.log = function() {
-  var console = jasmine.getGlobal().console;
-  if (console && console.log) {
-    if (console.log.apply) {
-      console.log.apply(console, arguments);
-    } else {
-      console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
-    }
-  }
-};
-
-jasmine.TrivialReporter.prototype.getLocation = function() {
-  return this.document.location;
-};
-
-jasmine.TrivialReporter.prototype.specFilter = function(spec) {
-  var paramMap = {};
-  var params = this.getLocation().search.substring(1).split('&');
-  for (var i = 0; i < params.length; i++) {
-    var p = params[i].split('=');
-    paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
-  }
-
-  if (!paramMap.spec) {
-    return true;
-  }
-  return spec.getFullName().indexOf(paramMap.spec) === 0;
-};
diff --git a/vendor/jasmine/jasmine.css b/vendor/jasmine/jasmine.css
deleted file mode 100644
index 8c008dc7..00000000
--- a/vendor/jasmine/jasmine.css
+++ /dev/null
@@ -1,82 +0,0 @@
-body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
-
-#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
-#HTMLReporter a { text-decoration: none; }
-#HTMLReporter a:hover { text-decoration: underline; }
-#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
-#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
-#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
-#HTMLReporter .version { color: #aaaaaa; }
-#HTMLReporter .banner { margin-top: 14px; }
-#HTMLReporter .duration { color: #aaaaaa; float: right; }
-#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
-#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
-#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
-#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
-#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
-#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
-#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
-#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
-#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
-#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
-#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
-#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
-#HTMLReporter .runningAlert { background-color: #666666; }
-#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
-#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
-#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
-#HTMLReporter .passingAlert { background-color: #a6b779; }
-#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
-#HTMLReporter .failingAlert { background-color: #cf867e; }
-#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
-#HTMLReporter .results { margin-top: 14px; }
-#HTMLReporter #details { display: none; }
-#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
-#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
-#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
-#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
-#HTMLReporter.showDetails .summary { display: none; }
-#HTMLReporter.showDetails #details { display: block; }
-#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
-#HTMLReporter .summary { margin-top: 14px; }
-#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
-#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
-#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
-#HTMLReporter .description + .suite { margin-top: 0; }
-#HTMLReporter .suite { margin-top: 14px; }
-#HTMLReporter .suite a { color: #333333; }
-#HTMLReporter #details .specDetail { margin-bottom: 28px; }
-#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
-#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
-#HTMLReporter .resultMessage span.result { display: block; }
-#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
-
-#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
-#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
-#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
-#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
-#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
-#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
-#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
-#TrivialReporter .runner.running { background-color: yellow; }
-#TrivialReporter .options { text-align: right; font-size: .8em; }
-#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
-#TrivialReporter .suite .suite { margin: 5px; }
-#TrivialReporter .suite.passed { background-color: #dfd; }
-#TrivialReporter .suite.failed { background-color: #fdd; }
-#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
-#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
-#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
-#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
-#TrivialReporter .spec.skipped { background-color: #bbb; }
-#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
-#TrivialReporter .passed { background-color: #cfc; display: none; }
-#TrivialReporter .failed { background-color: #fbb; }
-#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
-#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
-#TrivialReporter .resultMessage .mismatch { color: black; }
-#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
-#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
-#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
-#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
-#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
diff --git a/vendor/jasmine/jasmine.js b/vendor/jasmine/jasmine.js
deleted file mode 100644
index 6b3459b9..00000000
--- a/vendor/jasmine/jasmine.js
+++ /dev/null
@@ -1,2600 +0,0 @@
-var isCommonJS = typeof window == "undefined" && typeof exports == "object";
-
-/**
- * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
- *
- * @namespace
- */
-var jasmine = {};
-if (isCommonJS) exports.jasmine = jasmine;
-/**
- * @private
- */
-jasmine.unimplementedMethod_ = function() {
-  throw new Error("unimplemented method");
-};
-
-/**
- * Use jasmine.undefined instead of undefined, since undefined is just
- * a plain old variable and may be redefined by somebody else.
- *
- * @private
- */
-jasmine.undefined = jasmine.___undefined___;
-
-/**
- * Show diagnostic messages in the console if set to true
- *
- */
-jasmine.VERBOSE = false;
-
-/**
- * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
- *
- */
-jasmine.DEFAULT_UPDATE_INTERVAL = 250;
-
-/**
- * Maximum levels of nesting that will be included when an object is pretty-printed
- */
-jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
-
-/**
- * Default timeout interval in milliseconds for waitsFor() blocks.
- */
-jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
-
-/**
- * By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
- * Set to false to let the exception bubble up in the browser.
- *
- */
-jasmine.CATCH_EXCEPTIONS = true;
-
-jasmine.getGlobal = function() {
-  function getGlobal() {
-    return this;
-  }
-
-  return getGlobal();
-};
-
-/**
- * Allows for bound functions to be compared.  Internal use only.
- *
- * @ignore
- * @private
- * @param base {Object} bound 'this' for the function
- * @param name {Function} function to find
- */
-jasmine.bindOriginal_ = function(base, name) {
-  var original = base[name];
-  if (original.apply) {
-    return function() {
-      return original.apply(base, arguments);
-    };
-  } else {
-    // IE support
-    return jasmine.getGlobal()[name];
-  }
-};
-
-jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');
-jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');
-jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');
-jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');
-
-jasmine.MessageResult = function(values) {
-  this.type = 'log';
-  this.values = values;
-  this.trace = new Error(); // todo: test better
-};
-
-jasmine.MessageResult.prototype.toString = function() {
-  var text = "";
-  for (var i = 0; i < this.values.length; i++) {
-    if (i > 0) text += " ";
-    if (jasmine.isString_(this.values[i])) {
-      text += this.values[i];
-    } else {
-      text += jasmine.pp(this.values[i]);
-    }
-  }
-  return text;
-};
-
-jasmine.ExpectationResult = function(params) {
-  this.type = 'expect';
-  this.matcherName = params.matcherName;
-  this.passed_ = params.passed;
-  this.expected = params.expected;
-  this.actual = params.actual;
-  this.message = this.passed_ ? 'Passed.' : params.message;
-
-  var trace = (params.trace || new Error(this.message));
-  this.trace = this.passed_ ? '' : trace;
-};
-
-jasmine.ExpectationResult.prototype.toString = function () {
-  return this.message;
-};
-
-jasmine.ExpectationResult.prototype.passed = function () {
-  return this.passed_;
-};
-
-/**
- * Getter for the Jasmine environment. Ensures one gets created
- */
-jasmine.getEnv = function() {
-  var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
-  return env;
-};
-
-/**
- * @ignore
- * @private
- * @param value
- * @returns {Boolean}
- */
-jasmine.isArray_ = function(value) {
-  return jasmine.isA_("Array", value);
-};
-
-/**
- * @ignore
- * @private
- * @param value
- * @returns {Boolean}
- */
-jasmine.isString_ = function(value) {
-  return jasmine.isA_("String", value);
-};
-
-/**
- * @ignore
- * @private
- * @param value
- * @returns {Boolean}
- */
-jasmine.isNumber_ = function(value) {
-  return jasmine.isA_("Number", value);
-};
-
-/**
- * @ignore
- * @private
- * @param {String} typeName
- * @param value
- * @returns {Boolean}
- */
-jasmine.isA_ = function(typeName, value) {
-  return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
-};
-
-/**
- * Pretty printer for expecations.  Takes any object and turns it into a human-readable string.
- *
- * @param value {Object} an object to be outputted
- * @returns {String}
- */
-jasmine.pp = function(value) {
-  var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
-  stringPrettyPrinter.format(value);
-  return stringPrettyPrinter.string;
-};
-
-/**
- * Returns true if the object is a DOM Node.
- *
- * @param {Object} obj object to check
- * @returns {Boolean}
- */
-jasmine.isDomNode = function(obj) {
-  return obj.nodeType > 0;
-};
-
-/**
- * Returns a matchable 'generic' object of the class type.  For use in expecations of type when values don't matter.
- *
- * @example
- * // don't care about which function is passed in, as long as it's a function
- * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
- *
- * @param {Class} clazz
- * @returns matchable object of the type clazz
- */
-jasmine.any = function(clazz) {
-  return new jasmine.Matchers.Any(clazz);
-};
-
-/**
- * Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
- * attributes on the object.
- *
- * @example
- * // don't care about any other attributes than foo.
- * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
- *
- * @param sample {Object} sample
- * @returns matchable object for the sample
- */
-jasmine.objectContaining = function (sample) {
-    return new jasmine.Matchers.ObjectContaining(sample);
-};
-
-/**
- * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
- *
- * Spies should be created in test setup, before expectations.  They can then be checked, using the standard Jasmine
- * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
- *
- * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
- *
- * Spies are torn down at the end of every spec.
- *
- * Note: Do not call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
- *
- * @example
- * // a stub
- * var myStub = jasmine.createSpy('myStub');  // can be used anywhere
- *
- * // spy example
- * var foo = {
- *   not: function(bool) { return !bool; }
- * }
- *
- * // actual foo.not will not be called, execution stops
- * spyOn(foo, 'not');
-
- // foo.not spied upon, execution will continue to implementation
- * spyOn(foo, 'not').andCallThrough();
- *
- * // fake example
- * var foo = {
- *   not: function(bool) { return !bool; }
- * }
- *
- * // foo.not(val) will return val
- * spyOn(foo, 'not').andCallFake(function(value) {return value;});
- *
- * // mock example
- * foo.not(7 == 7);
- * expect(foo.not).toHaveBeenCalled();
- * expect(foo.not).toHaveBeenCalledWith(true);
- *
- * @constructor
- * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
- * @param {String} name
- */
-jasmine.Spy = function(name) {
-  /**
-   * The name of the spy, if provided.
-   */
-  this.identity = name || 'unknown';
-  /**
-   *  Is this Object a spy?
-   */
-  this.isSpy = true;
-  /**
-   * The actual function this spy stubs.
-   */
-  this.plan = function() {
-  };
-  /**
-   * Tracking of the most recent call to the spy.
-   * @example
-   * var mySpy = jasmine.createSpy('foo');
-   * mySpy(1, 2);
-   * mySpy.mostRecentCall.args = [1, 2];
-   */
-  this.mostRecentCall = {};
-
-  /**
-   * Holds arguments for each call to the spy, indexed by call count
-   * @example
-   * var mySpy = jasmine.createSpy('foo');
-   * mySpy(1, 2);
-   * mySpy(7, 8);
-   * mySpy.mostRecentCall.args = [7, 8];
-   * mySpy.argsForCall[0] = [1, 2];
-   * mySpy.argsForCall[1] = [7, 8];
-   */
-  this.argsForCall = [];
-  this.calls = [];
-};
-
-/**
- * Tells a spy to call through to the actual implemenatation.
- *
- * @example
- * var foo = {
- *   bar: function() { // do some stuff }
- * }
- *
- * // defining a spy on an existing property: foo.bar
- * spyOn(foo, 'bar').andCallThrough();
- */
-jasmine.Spy.prototype.andCallThrough = function() {
-  this.plan = this.originalValue;
-  return this;
-};
-
-/**
- * For setting the return value of a spy.
- *
- * @example
- * // defining a spy from scratch: foo() returns 'baz'
- * var foo = jasmine.createSpy('spy on foo').andReturn('baz');
- *
- * // defining a spy on an existing property: foo.bar() returns 'baz'
- * spyOn(foo, 'bar').andReturn('baz');
- *
- * @param {Object} value
- */
-jasmine.Spy.prototype.andReturn = function(value) {
-  this.plan = function() {
-    return value;
-  };
-  return this;
-};
-
-/**
- * For throwing an exception when a spy is called.
- *
- * @example
- * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'
- * var foo = jasmine.createSpy('spy on foo').andThrow('baz');
- *
- * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
- * spyOn(foo, 'bar').andThrow('baz');
- *
- * @param {String} exceptionMsg
- */
-jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
-  this.plan = function() {
-    throw exceptionMsg;
-  };
-  return this;
-};
-
-/**
- * Calls an alternate implementation when a spy is called.
- *
- * @example
- * var baz = function() {
- *   // do some stuff, return something
- * }
- * // defining a spy from scratch: foo() calls the function baz
- * var foo = jasmine.createSpy('spy on foo').andCall(baz);
- *
- * // defining a spy on an existing property: foo.bar() calls an anonymnous function
- * spyOn(foo, 'bar').andCall(function() { return 'baz';} );
- *
- * @param {Function} fakeFunc
- */
-jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
-  this.plan = fakeFunc;
-  return this;
-};
-
-/**
- * Resets all of a spy's the tracking variables so that it can be used again.
- *
- * @example
- * spyOn(foo, 'bar');
- *
- * foo.bar();
- *
- * expect(foo.bar.callCount).toEqual(1);
- *
- * foo.bar.reset();
- *
- * expect(foo.bar.callCount).toEqual(0);
- */
-jasmine.Spy.prototype.reset = function() {
-  this.wasCalled = false;
-  this.callCount = 0;
-  this.argsForCall = [];
-  this.calls = [];
-  this.mostRecentCall = {};
-};
-
-jasmine.createSpy = function(name) {
-
-  var spyObj = function() {
-    spyObj.wasCalled = true;
-    spyObj.callCount++;
-    var args = jasmine.util.argsToArray(arguments);
-    spyObj.mostRecentCall.object = this;
-    spyObj.mostRecentCall.args = args;
-    spyObj.argsForCall.push(args);
-    spyObj.calls.push({object: this, args: args});
-    return spyObj.plan.apply(this, arguments);
-  };
-
-  var spy = new jasmine.Spy(name);
-
-  for (var prop in spy) {
-    spyObj[prop] = spy[prop];
-  }
-
-  spyObj.reset();
-
-  return spyObj;
-};
-
-/**
- * Determines whether an object is a spy.
- *
- * @param {jasmine.Spy|Object} putativeSpy
- * @returns {Boolean}
- */
-jasmine.isSpy = function(putativeSpy) {
-  return putativeSpy && putativeSpy.isSpy;
-};
-
-/**
- * Creates a more complicated spy: an Object that has every property a function that is a spy.  Used for stubbing something
- * large in one call.
- *
- * @param {String} baseName name of spy class
- * @param {Array} methodNames array of names of methods to make spies
- */
-jasmine.createSpyObj = function(baseName, methodNames) {
-  if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
-    throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
-  }
-  var obj = {};
-  for (var i = 0; i < methodNames.length; i++) {
-    obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
-  }
-  return obj;
-};
-
-/**
- * All parameters are pretty-printed and concatenated together, then written to the current spec's output.
- *
- * Be careful not to leave calls to jasmine.log in production code.
- */
-jasmine.log = function() {
-  var spec = jasmine.getEnv().currentSpec;
-  spec.log.apply(spec, arguments);
-};
-
-/**
- * Function that installs a spy on an existing object's method name.  Used within a Spec to create a spy.
- *
- * @example
- * // spy example
- * var foo = {
- *   not: function(bool) { return !bool; }
- * }
- * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
- *
- * @see jasmine.createSpy
- * @param obj
- * @param methodName
- * @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
- */
-var spyOn = function(obj, methodName) {
-  return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
-};
-if (isCommonJS) exports.spyOn = spyOn;
-
-/**
- * Creates a Jasmine spec that will be added to the current suite.
- *
- * // TODO: pending tests
- *
- * @example
- * it('should be true', function() {
- *   expect(true).toEqual(true);
- * });
- *
- * @param {String} desc description of this specification
- * @param {Function} func defines the preconditions and expectations of the spec
- */
-var it = function(desc, func) {
-  return jasmine.getEnv().it(desc, func);
-};
-if (isCommonJS) exports.it = it;
-
-/**
- * Creates a disabled Jasmine spec.
- *
- * A convenience method that allows existing specs to be disabled temporarily during development.
- *
- * @param {String} desc description of this specification
- * @param {Function} func defines the preconditions and expectations of the spec
- */
-var xit = function(desc, func) {
-  return jasmine.getEnv().xit(desc, func);
-};
-if (isCommonJS) exports.xit = xit;
-
-/**
- * Starts a chain for a Jasmine expectation.
- *
- * It is passed an Object that is the actual value and should chain to one of the many
- * jasmine.Matchers functions.
- *
- * @param {Object} actual Actual value to test against and expected value
- * @return {jasmine.Matchers}
- */
-var expect = function(actual) {
-  return jasmine.getEnv().currentSpec.expect(actual);
-};
-if (isCommonJS) exports.expect = expect;
-
-/**
- * Defines part of a jasmine spec.  Used in cominbination with waits or waitsFor in asynchrnous specs.
- *
- * @param {Function} func Function that defines part of a jasmine spec.
- */
-var runs = function(func) {
-  jasmine.getEnv().currentSpec.runs(func);
-};
-if (isCommonJS) exports.runs = runs;
-
-/**
- * Waits a fixed time period before moving to the next block.
- *
- * @deprecated Use waitsFor() instead
- * @param {Number} timeout milliseconds to wait
- */
-var waits = function(timeout) {
-  jasmine.getEnv().currentSpec.waits(timeout);
-};
-if (isCommonJS) exports.waits = waits;
-
-/**
- * Waits for the latchFunction to return true before proceeding to the next block.
- *
- * @param {Function} latchFunction
- * @param {String} optional_timeoutMessage
- * @param {Number} optional_timeout
- */
-var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
-  jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
-};
-if (isCommonJS) exports.waitsFor = waitsFor;
-
-/**
- * A function that is called before each spec in a suite.
- *
- * Used for spec setup, including validating assumptions.
- *
- * @param {Function} beforeEachFunction
- */
-var beforeEach = function(beforeEachFunction) {
-  jasmine.getEnv().beforeEach(beforeEachFunction);
-};
-if (isCommonJS) exports.beforeEach = beforeEach;
-
-/**
- * A function that is called after each spec in a suite.
- *
- * Used for restoring any state that is hijacked during spec execution.
- *
- * @param {Function} afterEachFunction
- */
-var afterEach = function(afterEachFunction) {
-  jasmine.getEnv().afterEach(afterEachFunction);
-};
-if (isCommonJS) exports.afterEach = afterEach;
-
-/**
- * Defines a suite of specifications.
- *
- * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
- * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
- * of setup in some tests.
- *
- * @example
- * // TODO: a simple suite
- *
- * // TODO: a simple suite with a nested describe block
- *
- * @param {String} description A string, usually the class under test.
- * @param {Function} specDefinitions function that defines several specs.
- */
-var describe = function(description, specDefinitions) {
-  return jasmine.getEnv().describe(description, specDefinitions);
-};
-if (isCommonJS) exports.describe = describe;
-
-/**
- * Disables a suite of specifications.  Used to disable some suites in a file, or files, temporarily during development.
- *
- * @param {String} description A string, usually the class under test.
- * @param {Function} specDefinitions function that defines several specs.
- */
-var xdescribe = function(description, specDefinitions) {
-  return jasmine.getEnv().xdescribe(description, specDefinitions);
-};
-if (isCommonJS) exports.xdescribe = xdescribe;
-
-
-// Provide the XMLHttpRequest class for IE 5.x-6.x:
-jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
-  function tryIt(f) {
-    try {
-      return f();
-    } catch(e) {
-    }
-    return null;
-  }
-
-  var xhr = tryIt(function() {
-    return new ActiveXObject("Msxml2.XMLHTTP.6.0");
-  }) ||
-    tryIt(function() {
-      return new ActiveXObject("Msxml2.XMLHTTP.3.0");
-    }) ||
-    tryIt(function() {
-      return new ActiveXObject("Msxml2.XMLHTTP");
-    }) ||
-    tryIt(function() {
-      return new ActiveXObject("Microsoft.XMLHTTP");
-    });
-
-  if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
-
-  return xhr;
-} : XMLHttpRequest;
-/**
- * @namespace
- */
-jasmine.util = {};
-
-/**
- * Declare that a child class inherit it's prototype from the parent class.
- *
- * @private
- * @param {Function} childClass
- * @param {Function} parentClass
- */
-jasmine.util.inherit = function(childClass, parentClass) {
-  /**
-   * @private
-   */
-  var subclass = function() {
-  };
-  subclass.prototype = parentClass.prototype;
-  childClass.prototype = new subclass();
-};
-
-jasmine.util.formatException = function(e) {
-  var lineNumber;
-  if (e.line) {
-    lineNumber = e.line;
-  }
-  else if (e.lineNumber) {
-    lineNumber = e.lineNumber;
-  }
-
-  var file;
-
-  if (e.sourceURL) {
-    file = e.sourceURL;
-  }
-  else if (e.fileName) {
-    file = e.fileName;
-  }
-
-  var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
-
-  if (file && lineNumber) {
-    message += ' in ' + file + ' (line ' + lineNumber + ')';
-  }
-
-  return message;
-};
-
-jasmine.util.htmlEscape = function(str) {
-  if (!str) return str;
-  return str.replace(/&/g, '&')
-    .replace(//g, '>');
-};
-
-jasmine.util.argsToArray = function(args) {
-  var arrayOfArgs = [];
-  for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
-  return arrayOfArgs;
-};
-
-jasmine.util.extend = function(destination, source) {
-  for (var property in source) destination[property] = source[property];
-  return destination;
-};
-
-/**
- * Environment for Jasmine
- *
- * @constructor
- */
-jasmine.Env = function() {
-  this.currentSpec = null;
-  this.currentSuite = null;
-  this.currentRunner_ = new jasmine.Runner(this);
-
-  this.reporter = new jasmine.MultiReporter();
-
-  this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
-  this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
-  this.lastUpdate = 0;
-  this.specFilter = function() {
-    return true;
-  };
-
-  this.nextSpecId_ = 0;
-  this.nextSuiteId_ = 0;
-  this.equalityTesters_ = [];
-
-  // wrap matchers
-  this.matchersClass = function() {
-    jasmine.Matchers.apply(this, arguments);
-  };
-  jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
-
-  jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
-};
-
-
-jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
-jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
-jasmine.Env.prototype.setInterval = jasmine.setInterval;
-jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
-
-/**
- * @returns an object containing jasmine version build info, if set.
- */
-jasmine.Env.prototype.version = function () {
-  if (jasmine.version_) {
-    return jasmine.version_;
-  } else {
-    throw new Error('Version not set');
-  }
-};
-
-/**
- * @returns string containing jasmine version build info, if set.
- */
-jasmine.Env.prototype.versionString = function() {
-  if (!jasmine.version_) {
-    return "version unknown";
-  }
-
-  var version = this.version();
-  var versionString = version.major + "." + version.minor + "." + version.build;
-  if (version.release_candidate) {
-    versionString += ".rc" + version.release_candidate;
-  }
-  versionString += " revision " + version.revision;
-  return versionString;
-};
-
-/**
- * @returns a sequential integer starting at 0
- */
-jasmine.Env.prototype.nextSpecId = function () {
-  return this.nextSpecId_++;
-};
-
-/**
- * @returns a sequential integer starting at 0
- */
-jasmine.Env.prototype.nextSuiteId = function () {
-  return this.nextSuiteId_++;
-};
-
-/**
- * Register a reporter to receive status updates from Jasmine.
- * @param {jasmine.Reporter} reporter An object which will receive status updates.
- */
-jasmine.Env.prototype.addReporter = function(reporter) {
-  this.reporter.addReporter(reporter);
-};
-
-jasmine.Env.prototype.execute = function() {
-  this.currentRunner_.execute();
-};
-
-jasmine.Env.prototype.describe = function(description, specDefinitions) {
-  var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
-
-  var parentSuite = this.currentSuite;
-  if (parentSuite) {
-    parentSuite.add(suite);
-  } else {
-    this.currentRunner_.add(suite);
-  }
-
-  this.currentSuite = suite;
-
-  var declarationError = null;
-  try {
-    specDefinitions.call(suite);
-  } catch(e) {
-    declarationError = e;
-  }
-
-  if (declarationError) {
-    this.it("encountered a declaration exception", function() {
-      throw declarationError;
-    });
-  }
-
-  this.currentSuite = parentSuite;
-
-  return suite;
-};
-
-jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
-  if (this.currentSuite) {
-    this.currentSuite.beforeEach(beforeEachFunction);
-  } else {
-    this.currentRunner_.beforeEach(beforeEachFunction);
-  }
-};
-
-jasmine.Env.prototype.currentRunner = function () {
-  return this.currentRunner_;
-};
-
-jasmine.Env.prototype.afterEach = function(afterEachFunction) {
-  if (this.currentSuite) {
-    this.currentSuite.afterEach(afterEachFunction);
-  } else {
-    this.currentRunner_.afterEach(afterEachFunction);
-  }
-
-};
-
-jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
-  return {
-    execute: function() {
-    }
-  };
-};
-
-jasmine.Env.prototype.it = function(description, func) {
-  var spec = new jasmine.Spec(this, this.currentSuite, description);
-  this.currentSuite.add(spec);
-  this.currentSpec = spec;
-
-  if (func) {
-    spec.runs(func);
-  }
-
-  return spec;
-};
-
-jasmine.Env.prototype.xit = function(desc, func) {
-  return {
-    id: this.nextSpecId(),
-    runs: function() {
-    }
-  };
-};
-
-jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
-  if (a.source != b.source)
-    mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
-
-  if (a.ignoreCase != b.ignoreCase)
-    mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
-
-  if (a.global != b.global)
-    mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
-
-  if (a.multiline != b.multiline)
-    mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
-
-  if (a.sticky != b.sticky)
-    mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
-
-  return (mismatchValues.length === 0);
-};
-
-jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
-  if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
-    return true;
-  }
-
-  a.__Jasmine_been_here_before__ = b;
-  b.__Jasmine_been_here_before__ = a;
-
-  var hasKey = function(obj, keyName) {
-    return obj !== null && obj[keyName] !== jasmine.undefined;
-  };
-
-  for (var property in b) {
-    if (!hasKey(a, property) && hasKey(b, property)) {
-      mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
-    }
-  }
-  for (property in a) {
-    if (!hasKey(b, property) && hasKey(a, property)) {
-      mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
-    }
-  }
-  for (property in b) {
-    if (property == '__Jasmine_been_here_before__') continue;
-    if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
-      mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
-    }
-  }
-
-  if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
-    mismatchValues.push("arrays were not the same length");
-  }
-
-  delete a.__Jasmine_been_here_before__;
-  delete b.__Jasmine_been_here_before__;
-  return (mismatchKeys.length === 0 && mismatchValues.length === 0);
-};
-
-jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
-  mismatchKeys = mismatchKeys || [];
-  mismatchValues = mismatchValues || [];
-
-  for (var i = 0; i < this.equalityTesters_.length; i++) {
-    var equalityTester = this.equalityTesters_[i];
-    var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
-    if (result !== jasmine.undefined) return result;
-  }
-
-  if (a === b) return true;
-
-  if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
-    return (a == jasmine.undefined && b == jasmine.undefined);
-  }
-
-  if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
-    return a === b;
-  }
-
-  if (a instanceof Date && b instanceof Date) {
-    return a.getTime() == b.getTime();
-  }
-
-  if (a.jasmineMatches) {
-    return a.jasmineMatches(b);
-  }
-
-  if (b.jasmineMatches) {
-    return b.jasmineMatches(a);
-  }
-
-  if (a instanceof jasmine.Matchers.ObjectContaining) {
-    return a.matches(b);
-  }
-
-  if (b instanceof jasmine.Matchers.ObjectContaining) {
-    return b.matches(a);
-  }
-
-  if (jasmine.isString_(a) && jasmine.isString_(b)) {
-    return (a == b);
-  }
-
-  if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
-    return (a == b);
-  }
-
-  if (a instanceof RegExp && b instanceof RegExp) {
-    return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
-  }
-
-  if (typeof a === "object" && typeof b === "object") {
-    return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
-  }
-
-  //Straight check
-  return (a === b);
-};
-
-jasmine.Env.prototype.contains_ = function(haystack, needle) {
-  if (jasmine.isArray_(haystack)) {
-    for (var i = 0; i < haystack.length; i++) {
-      if (this.equals_(haystack[i], needle)) return true;
-    }
-    return false;
-  }
-  return haystack.indexOf(needle) >= 0;
-};
-
-jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
-  this.equalityTesters_.push(equalityTester);
-};
-/** No-op base class for Jasmine reporters.
- *
- * @constructor
- */
-jasmine.Reporter = function() {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportSpecResults = function(spec) {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.log = function(str) {
-};
-
-/**
- * Blocks are functions with executable code that make up a spec.
- *
- * @constructor
- * @param {jasmine.Env} env
- * @param {Function} func
- * @param {jasmine.Spec} spec
- */
-jasmine.Block = function(env, func, spec) {
-  this.env = env;
-  this.func = func;
-  this.spec = spec;
-};
-
-jasmine.Block.prototype.execute = function(onComplete) {
-  if (!jasmine.CATCH_EXCEPTIONS) {
-    this.func.apply(this.spec);
-  }
-  else {
-    try {
-      this.func.apply(this.spec);
-    } catch (e) {
-      this.spec.fail(e);
-    }
-  }
-  onComplete();
-};
-/** JavaScript API reporter.
- *
- * @constructor
- */
-jasmine.JsApiReporter = function() {
-  this.started = false;
-  this.finished = false;
-  this.suites_ = [];
-  this.results_ = {};
-};
-
-jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
-  this.started = true;
-  var suites = runner.topLevelSuites();
-  for (var i = 0; i < suites.length; i++) {
-    var suite = suites[i];
-    this.suites_.push(this.summarize_(suite));
-  }
-};
-
-jasmine.JsApiReporter.prototype.suites = function() {
-  return this.suites_;
-};
-
-jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
-  var isSuite = suiteOrSpec instanceof jasmine.Suite;
-  var summary = {
-    id: suiteOrSpec.id,
-    name: suiteOrSpec.description,
-    type: isSuite ? 'suite' : 'spec',
-    children: []
-  };
-  
-  if (isSuite) {
-    var children = suiteOrSpec.children();
-    for (var i = 0; i < children.length; i++) {
-      summary.children.push(this.summarize_(children[i]));
-    }
-  }
-  return summary;
-};
-
-jasmine.JsApiReporter.prototype.results = function() {
-  return this.results_;
-};
-
-jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
-  return this.results_[specId];
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
-  this.finished = true;
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
-  this.results_[spec.id] = {
-    messages: spec.results().getItems(),
-    result: spec.results().failedCount > 0 ? "failed" : "passed"
-  };
-};
-
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.log = function(str) {
-};
-
-jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
-  var results = {};
-  for (var i = 0; i < specIds.length; i++) {
-    var specId = specIds[i];
-    results[specId] = this.summarizeResult_(this.results_[specId]);
-  }
-  return results;
-};
-
-jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
-  var summaryMessages = [];
-  var messagesLength = result.messages.length;
-  for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
-    var resultMessage = result.messages[messageIndex];
-    summaryMessages.push({
-      text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
-      passed: resultMessage.passed ? resultMessage.passed() : true,
-      type: resultMessage.type,
-      message: resultMessage.message,
-      trace: {
-        stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
-      }
-    });
-  }
-
-  return {
-    result : result.result,
-    messages : summaryMessages
-  };
-};
-
-/**
- * @constructor
- * @param {jasmine.Env} env
- * @param actual
- * @param {jasmine.Spec} spec
- */
-jasmine.Matchers = function(env, actual, spec, opt_isNot) {
-  this.env = env;
-  this.actual = actual;
-  this.spec = spec;
-  this.isNot = opt_isNot || false;
-  this.reportWasCalled_ = false;
-};
-
-// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
-jasmine.Matchers.pp = function(str) {
-  throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
-};
-
-// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
-jasmine.Matchers.prototype.report = function(result, failing_message, details) {
-  throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
-};
-
-jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
-  for (var methodName in prototype) {
-    if (methodName == 'report') continue;
-    var orig = prototype[methodName];
-    matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
-  }
-};
-
-jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
-  return function() {
-    var matcherArgs = jasmine.util.argsToArray(arguments);
-    var result = matcherFunction.apply(this, arguments);
-
-    if (this.isNot) {
-      result = !result;
-    }
-
-    if (this.reportWasCalled_) return result;
-
-    var message;
-    if (!result) {
-      if (this.message) {
-        message = this.message.apply(this, arguments);
-        if (jasmine.isArray_(message)) {
-          message = message[this.isNot ? 1 : 0];
-        }
-      } else {
-        var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
-        message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
-        if (matcherArgs.length > 0) {
-          for (var i = 0; i < matcherArgs.length; i++) {
-            if (i > 0) message += ",";
-            message += " " + jasmine.pp(matcherArgs[i]);
-          }
-        }
-        message += ".";
-      }
-    }
-    var expectationResult = new jasmine.ExpectationResult({
-      matcherName: matcherName,
-      passed: result,
-      expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
-      actual: this.actual,
-      message: message
-    });
-    this.spec.addMatcherResult(expectationResult);
-    return jasmine.undefined;
-  };
-};
-
-
-
-
-/**
- * toBe: compares the actual to the expected using ===
- * @param expected
- */
-jasmine.Matchers.prototype.toBe = function(expected) {
-  return this.actual === expected;
-};
-
-/**
- * toNotBe: compares the actual to the expected using !==
- * @param expected
- * @deprecated as of 1.0. Use not.toBe() instead.
- */
-jasmine.Matchers.prototype.toNotBe = function(expected) {
-  return this.actual !== expected;
-};
-
-/**
- * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
- *
- * @param expected
- */
-jasmine.Matchers.prototype.toEqual = function(expected) {
-  return this.env.equals_(this.actual, expected);
-};
-
-/**
- * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
- * @param expected
- * @deprecated as of 1.0. Use not.toEqual() instead.
- */
-jasmine.Matchers.prototype.toNotEqual = function(expected) {
-  return !this.env.equals_(this.actual, expected);
-};
-
-/**
- * Matcher that compares the actual to the expected using a regular expression.  Constructs a RegExp, so takes
- * a pattern or a String.
- *
- * @param expected
- */
-jasmine.Matchers.prototype.toMatch = function(expected) {
-  return new RegExp(expected).test(this.actual);
-};
-
-/**
- * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
- * @param expected
- * @deprecated as of 1.0. Use not.toMatch() instead.
- */
-jasmine.Matchers.prototype.toNotMatch = function(expected) {
-  return !(new RegExp(expected).test(this.actual));
-};
-
-/**
- * Matcher that compares the actual to jasmine.undefined.
- */
-jasmine.Matchers.prototype.toBeDefined = function() {
-  return (this.actual !== jasmine.undefined);
-};
-
-/**
- * Matcher that compares the actual to jasmine.undefined.
- */
-jasmine.Matchers.prototype.toBeUndefined = function() {
-  return (this.actual === jasmine.undefined);
-};
-
-/**
- * Matcher that compares the actual to null.
- */
-jasmine.Matchers.prototype.toBeNull = function() {
-  return (this.actual === null);
-};
-
-/**
- * Matcher that compares the actual to NaN.
- */
-jasmine.Matchers.prototype.toBeNaN = function() {
-	this.message = function() {
-		return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
-	};
-
-	return (this.actual !== this.actual);
-};
-
-/**
- * Matcher that boolean not-nots the actual.
- */
-jasmine.Matchers.prototype.toBeTruthy = function() {
-  return !!this.actual;
-};
-
-
-/**
- * Matcher that boolean nots the actual.
- */
-jasmine.Matchers.prototype.toBeFalsy = function() {
-  return !this.actual;
-};
-
-
-/**
- * Matcher that checks to see if the actual, a Jasmine spy, was called.
- */
-jasmine.Matchers.prototype.toHaveBeenCalled = function() {
-  if (arguments.length > 0) {
-    throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
-  }
-
-  if (!jasmine.isSpy(this.actual)) {
-    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
-  }
-
-  this.message = function() {
-    return [
-      "Expected spy " + this.actual.identity + " to have been called.",
-      "Expected spy " + this.actual.identity + " not to have been called."
-    ];
-  };
-
-  return this.actual.wasCalled;
-};
-
-/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
-jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled;
-
-/**
- * Matcher that checks to see if the actual, a Jasmine spy, was not called.
- *
- * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead
- */
-jasmine.Matchers.prototype.wasNotCalled = function() {
-  if (arguments.length > 0) {
-    throw new Error('wasNotCalled does not take arguments');
-  }
-
-  if (!jasmine.isSpy(this.actual)) {
-    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
-  }
-
-  this.message = function() {
-    return [
-      "Expected spy " + this.actual.identity + " to not have been called.",
-      "Expected spy " + this.actual.identity + " to have been called."
-    ];
-  };
-
-  return !this.actual.wasCalled;
-};
-
-/**
- * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
- *
- * @example
- *
- */
-jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
-  var expectedArgs = jasmine.util.argsToArray(arguments);
-  if (!jasmine.isSpy(this.actual)) {
-    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
-  }
-  this.message = function() {
-    var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
-    var positiveMessage = "";
-    if (this.actual.callCount === 0) {
-      positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
-    } else {
-      positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
-    }
-    return [positiveMessage, invertedMessage];
-  };
-
-  return this.env.contains_(this.actual.argsForCall, expectedArgs);
-};
-
-/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
-jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith;
-
-/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
-jasmine.Matchers.prototype.wasNotCalledWith = function() {
-  var expectedArgs = jasmine.util.argsToArray(arguments);
-  if (!jasmine.isSpy(this.actual)) {
-    throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
-  }
-
-  this.message = function() {
-    return [
-      "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
-      "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
-    ];
-  };
-
-  return !this.env.contains_(this.actual.argsForCall, expectedArgs);
-};
-
-/**
- * Matcher that checks that the expected item is an element in the actual Array.
- *
- * @param {Object} expected
- */
-jasmine.Matchers.prototype.toContain = function(expected) {
-  return this.env.contains_(this.actual, expected);
-};
-
-/**
- * Matcher that checks that the expected item is NOT an element in the actual Array.
- *
- * @param {Object} expected
- * @deprecated as of 1.0. Use not.toContain() instead.
- */
-jasmine.Matchers.prototype.toNotContain = function(expected) {
-  return !this.env.contains_(this.actual, expected);
-};
-
-jasmine.Matchers.prototype.toBeLessThan = function(expected) {
-  return this.actual < expected;
-};
-
-jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
-  return this.actual > expected;
-};
-
-/**
- * Matcher that checks that the expected item is equal to the actual item
- * up to a given level of decimal precision (default 2).
- *
- * @param {Number} expected
- * @param {Number} precision, as number of decimal places
- */
-jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
-  if (!(precision === 0)) {
-    precision = precision || 2;
-  }
-  return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
-};
-
-/**
- * Matcher that checks that the expected exception was thrown by the actual.
- *
- * @param {String} [expected]
- */
-jasmine.Matchers.prototype.toThrow = function(expected) {
-  var result = false;
-  var exception;
-  if (typeof this.actual != 'function') {
-    throw new Error('Actual is not a function');
-  }
-  try {
-    this.actual();
-  } catch (e) {
-    exception = e;
-  }
-  if (exception) {
-    result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
-  }
-
-  var not = this.isNot ? "not " : "";
-
-  this.message = function() {
-    if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
-      return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
-    } else {
-      return "Expected function to throw an exception.";
-    }
-  };
-
-  return result;
-};
-
-jasmine.Matchers.Any = function(expectedClass) {
-  this.expectedClass = expectedClass;
-};
-
-jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
-  if (this.expectedClass == String) {
-    return typeof other == 'string' || other instanceof String;
-  }
-
-  if (this.expectedClass == Number) {
-    return typeof other == 'number' || other instanceof Number;
-  }
-
-  if (this.expectedClass == Function) {
-    return typeof other == 'function' || other instanceof Function;
-  }
-
-  if (this.expectedClass == Object) {
-    return typeof other == 'object';
-  }
-
-  return other instanceof this.expectedClass;
-};
-
-jasmine.Matchers.Any.prototype.jasmineToString = function() {
-  return '';
-};
-
-jasmine.Matchers.ObjectContaining = function (sample) {
-  this.sample = sample;
-};
-
-jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
-  mismatchKeys = mismatchKeys || [];
-  mismatchValues = mismatchValues || [];
-
-  var env = jasmine.getEnv();
-
-  var hasKey = function(obj, keyName) {
-    return obj != null && obj[keyName] !== jasmine.undefined;
-  };
-
-  for (var property in this.sample) {
-    if (!hasKey(other, property) && hasKey(this.sample, property)) {
-      mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
-    }
-    else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
-      mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
-    }
-  }
-
-  return (mismatchKeys.length === 0 && mismatchValues.length === 0);
-};
-
-jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {
-  return "";
-};
-// Mock setTimeout, clearTimeout
-// Contributed by Pivotal Computer Systems, www.pivotalsf.com
-
-jasmine.FakeTimer = function() {
-  this.reset();
-
-  var self = this;
-  self.setTimeout = function(funcToCall, millis) {
-    self.timeoutsMade++;
-    self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
-    return self.timeoutsMade;
-  };
-
-  self.setInterval = function(funcToCall, millis) {
-    self.timeoutsMade++;
-    self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
-    return self.timeoutsMade;
-  };
-
-  self.clearTimeout = function(timeoutKey) {
-    self.scheduledFunctions[timeoutKey] = jasmine.undefined;
-  };
-
-  self.clearInterval = function(timeoutKey) {
-    self.scheduledFunctions[timeoutKey] = jasmine.undefined;
-  };
-
-};
-
-jasmine.FakeTimer.prototype.reset = function() {
-  this.timeoutsMade = 0;
-  this.scheduledFunctions = {};
-  this.nowMillis = 0;
-};
-
-jasmine.FakeTimer.prototype.tick = function(millis) {
-  var oldMillis = this.nowMillis;
-  var newMillis = oldMillis + millis;
-  this.runFunctionsWithinRange(oldMillis, newMillis);
-  this.nowMillis = newMillis;
-};
-
-jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
-  var scheduledFunc;
-  var funcsToRun = [];
-  for (var timeoutKey in this.scheduledFunctions) {
-    scheduledFunc = this.scheduledFunctions[timeoutKey];
-    if (scheduledFunc != jasmine.undefined &&
-        scheduledFunc.runAtMillis >= oldMillis &&
-        scheduledFunc.runAtMillis <= nowMillis) {
-      funcsToRun.push(scheduledFunc);
-      this.scheduledFunctions[timeoutKey] = jasmine.undefined;
-    }
-  }
-
-  if (funcsToRun.length > 0) {
-    funcsToRun.sort(function(a, b) {
-      return a.runAtMillis - b.runAtMillis;
-    });
-    for (var i = 0; i < funcsToRun.length; ++i) {
-      try {
-        var funcToRun = funcsToRun[i];
-        this.nowMillis = funcToRun.runAtMillis;
-        funcToRun.funcToCall();
-        if (funcToRun.recurring) {
-          this.scheduleFunction(funcToRun.timeoutKey,
-              funcToRun.funcToCall,
-              funcToRun.millis,
-              true);
-        }
-      } catch(e) {
-      }
-    }
-    this.runFunctionsWithinRange(oldMillis, nowMillis);
-  }
-};
-
-jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
-  this.scheduledFunctions[timeoutKey] = {
-    runAtMillis: this.nowMillis + millis,
-    funcToCall: funcToCall,
-    recurring: recurring,
-    timeoutKey: timeoutKey,
-    millis: millis
-  };
-};
-
-/**
- * @namespace
- */
-jasmine.Clock = {
-  defaultFakeTimer: new jasmine.FakeTimer(),
-
-  reset: function() {
-    jasmine.Clock.assertInstalled();
-    jasmine.Clock.defaultFakeTimer.reset();
-  },
-
-  tick: function(millis) {
-    jasmine.Clock.assertInstalled();
-    jasmine.Clock.defaultFakeTimer.tick(millis);
-  },
-
-  runFunctionsWithinRange: function(oldMillis, nowMillis) {
-    jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
-  },
-
-  scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
-    jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
-  },
-
-  useMock: function() {
-    if (!jasmine.Clock.isInstalled()) {
-      var spec = jasmine.getEnv().currentSpec;
-      spec.after(jasmine.Clock.uninstallMock);
-
-      jasmine.Clock.installMock();
-    }
-  },
-
-  installMock: function() {
-    jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
-  },
-
-  uninstallMock: function() {
-    jasmine.Clock.assertInstalled();
-    jasmine.Clock.installed = jasmine.Clock.real;
-  },
-
-  real: {
-    setTimeout: jasmine.getGlobal().setTimeout,
-    clearTimeout: jasmine.getGlobal().clearTimeout,
-    setInterval: jasmine.getGlobal().setInterval,
-    clearInterval: jasmine.getGlobal().clearInterval
-  },
-
-  assertInstalled: function() {
-    if (!jasmine.Clock.isInstalled()) {
-      throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
-    }
-  },
-
-  isInstalled: function() {
-    return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
-  },
-
-  installed: null
-};
-jasmine.Clock.installed = jasmine.Clock.real;
-
-//else for IE support
-jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
-  if (jasmine.Clock.installed.setTimeout.apply) {
-    return jasmine.Clock.installed.setTimeout.apply(this, arguments);
-  } else {
-    return jasmine.Clock.installed.setTimeout(funcToCall, millis);
-  }
-};
-
-jasmine.getGlobal().setInterval = function(funcToCall, millis) {
-  if (jasmine.Clock.installed.setInterval.apply) {
-    return jasmine.Clock.installed.setInterval.apply(this, arguments);
-  } else {
-    return jasmine.Clock.installed.setInterval(funcToCall, millis);
-  }
-};
-
-jasmine.getGlobal().clearTimeout = function(timeoutKey) {
-  if (jasmine.Clock.installed.clearTimeout.apply) {
-    return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
-  } else {
-    return jasmine.Clock.installed.clearTimeout(timeoutKey);
-  }
-};
-
-jasmine.getGlobal().clearInterval = function(timeoutKey) {
-  if (jasmine.Clock.installed.clearTimeout.apply) {
-    return jasmine.Clock.installed.clearInterval.apply(this, arguments);
-  } else {
-    return jasmine.Clock.installed.clearInterval(timeoutKey);
-  }
-};
-
-/**
- * @constructor
- */
-jasmine.MultiReporter = function() {
-  this.subReporters_ = [];
-};
-jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
-
-jasmine.MultiReporter.prototype.addReporter = function(reporter) {
-  this.subReporters_.push(reporter);
-};
-
-(function() {
-  var functionNames = [
-    "reportRunnerStarting",
-    "reportRunnerResults",
-    "reportSuiteResults",
-    "reportSpecStarting",
-    "reportSpecResults",
-    "log"
-  ];
-  for (var i = 0; i < functionNames.length; i++) {
-    var functionName = functionNames[i];
-    jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
-      return function() {
-        for (var j = 0; j < this.subReporters_.length; j++) {
-          var subReporter = this.subReporters_[j];
-          if (subReporter[functionName]) {
-            subReporter[functionName].apply(subReporter, arguments);
-          }
-        }
-      };
-    })(functionName);
-  }
-})();
-/**
- * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
- *
- * @constructor
- */
-jasmine.NestedResults = function() {
-  /**
-   * The total count of results
-   */
-  this.totalCount = 0;
-  /**
-   * Number of passed results
-   */
-  this.passedCount = 0;
-  /**
-   * Number of failed results
-   */
-  this.failedCount = 0;
-  /**
-   * Was this suite/spec skipped?
-   */
-  this.skipped = false;
-  /**
-   * @ignore
-   */
-  this.items_ = [];
-};
-
-/**
- * Roll up the result counts.
- *
- * @param result
- */
-jasmine.NestedResults.prototype.rollupCounts = function(result) {
-  this.totalCount += result.totalCount;
-  this.passedCount += result.passedCount;
-  this.failedCount += result.failedCount;
-};
-
-/**
- * Adds a log message.
- * @param values Array of message parts which will be concatenated later.
- */
-jasmine.NestedResults.prototype.log = function(values) {
-  this.items_.push(new jasmine.MessageResult(values));
-};
-
-/**
- * Getter for the results: message & results.
- */
-jasmine.NestedResults.prototype.getItems = function() {
-  return this.items_;
-};
-
-/**
- * Adds a result, tracking counts (total, passed, & failed)
- * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
- */
-jasmine.NestedResults.prototype.addResult = function(result) {
-  if (result.type != 'log') {
-    if (result.items_) {
-      this.rollupCounts(result);
-    } else {
-      this.totalCount++;
-      if (result.passed()) {
-        this.passedCount++;
-      } else {
-        this.failedCount++;
-      }
-    }
-  }
-  this.items_.push(result);
-};
-
-/**
- * @returns {Boolean} True if everything below passed
- */
-jasmine.NestedResults.prototype.passed = function() {
-  return this.passedCount === this.totalCount;
-};
-/**
- * Base class for pretty printing for expectation results.
- */
-jasmine.PrettyPrinter = function() {
-  this.ppNestLevel_ = 0;
-};
-
-/**
- * Formats a value in a nice, human-readable string.
- *
- * @param value
- */
-jasmine.PrettyPrinter.prototype.format = function(value) {
-  this.ppNestLevel_++;
-  try {
-    if (value === jasmine.undefined) {
-      this.emitScalar('undefined');
-    } else if (value === null) {
-      this.emitScalar('null');
-    } else if (value === jasmine.getGlobal()) {
-      this.emitScalar('');
-    } else if (value.jasmineToString) {
-      this.emitScalar(value.jasmineToString());
-    } else if (typeof value === 'string') {
-      this.emitString(value);
-    } else if (jasmine.isSpy(value)) {
-      this.emitScalar("spy on " + value.identity);
-    } else if (value instanceof RegExp) {
-      this.emitScalar(value.toString());
-    } else if (typeof value === 'function') {
-      this.emitScalar('Function');
-    } else if (typeof value.nodeType === 'number') {
-      this.emitScalar('HTMLNode');
-    } else if (value instanceof Date) {
-      this.emitScalar('Date(' + value + ')');
-    } else if (value.__Jasmine_been_here_before__) {
-      this.emitScalar('');
-    } else if (jasmine.isArray_(value) || typeof value == 'object') {
-      value.__Jasmine_been_here_before__ = true;
-      if (jasmine.isArray_(value)) {
-        this.emitArray(value);
-      } else {
-        this.emitObject(value);
-      }
-      delete value.__Jasmine_been_here_before__;
-    } else {
-      this.emitScalar(value.toString());
-    }
-  } finally {
-    this.ppNestLevel_--;
-  }
-};
-
-jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
-  for (var property in obj) {
-    if (!obj.hasOwnProperty(property)) continue;
-    if (property == '__Jasmine_been_here_before__') continue;
-    fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && 
-                                         obj.__lookupGetter__(property) !== null) : false);
-  }
-};
-
-jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
-jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
-jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
-jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
-
-jasmine.StringPrettyPrinter = function() {
-  jasmine.PrettyPrinter.call(this);
-
-  this.string = '';
-};
-jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
-
-jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
-  this.append(value);
-};
-
-jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
-  this.append("'" + value + "'");
-};
-
-jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
-  if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
-    this.append("Array");
-    return;
-  }
-
-  this.append('[ ');
-  for (var i = 0; i < array.length; i++) {
-    if (i > 0) {
-      this.append(', ');
-    }
-    this.format(array[i]);
-  }
-  this.append(' ]');
-};
-
-jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
-  if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
-    this.append("Object");
-    return;
-  }
-
-  var self = this;
-  this.append('{ ');
-  var first = true;
-
-  this.iterateObject(obj, function(property, isGetter) {
-    if (first) {
-      first = false;
-    } else {
-      self.append(', ');
-    }
-
-    self.append(property);
-    self.append(' : ');
-    if (isGetter) {
-      self.append('');
-    } else {
-      self.format(obj[property]);
-    }
-  });
-
-  this.append(' }');
-};
-
-jasmine.StringPrettyPrinter.prototype.append = function(value) {
-  this.string += value;
-};
-jasmine.Queue = function(env) {
-  this.env = env;
-
-  // parallel to blocks. each true value in this array means the block will
-  // get executed even if we abort
-  this.ensured = [];
-  this.blocks = [];
-  this.running = false;
-  this.index = 0;
-  this.offset = 0;
-  this.abort = false;
-};
-
-jasmine.Queue.prototype.addBefore = function(block, ensure) {
-  if (ensure === jasmine.undefined) {
-    ensure = false;
-  }
-
-  this.blocks.unshift(block);
-  this.ensured.unshift(ensure);
-};
-
-jasmine.Queue.prototype.add = function(block, ensure) {
-  if (ensure === jasmine.undefined) {
-    ensure = false;
-  }
-
-  this.blocks.push(block);
-  this.ensured.push(ensure);
-};
-
-jasmine.Queue.prototype.insertNext = function(block, ensure) {
-  if (ensure === jasmine.undefined) {
-    ensure = false;
-  }
-
-  this.ensured.splice((this.index + this.offset + 1), 0, ensure);
-  this.blocks.splice((this.index + this.offset + 1), 0, block);
-  this.offset++;
-};
-
-jasmine.Queue.prototype.start = function(onComplete) {
-  this.running = true;
-  this.onComplete = onComplete;
-  this.next_();
-};
-
-jasmine.Queue.prototype.isRunning = function() {
-  return this.running;
-};
-
-jasmine.Queue.LOOP_DONT_RECURSE = true;
-
-jasmine.Queue.prototype.next_ = function() {
-  var self = this;
-  var goAgain = true;
-
-  while (goAgain) {
-    goAgain = false;
-    
-    if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
-      var calledSynchronously = true;
-      var completedSynchronously = false;
-
-      var onComplete = function () {
-        if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
-          completedSynchronously = true;
-          return;
-        }
-
-        if (self.blocks[self.index].abort) {
-          self.abort = true;
-        }
-
-        self.offset = 0;
-        self.index++;
-
-        var now = new Date().getTime();
-        if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
-          self.env.lastUpdate = now;
-          self.env.setTimeout(function() {
-            self.next_();
-          }, 0);
-        } else {
-          if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
-            goAgain = true;
-          } else {
-            self.next_();
-          }
-        }
-      };
-      self.blocks[self.index].execute(onComplete);
-
-      calledSynchronously = false;
-      if (completedSynchronously) {
-        onComplete();
-      }
-      
-    } else {
-      self.running = false;
-      if (self.onComplete) {
-        self.onComplete();
-      }
-    }
-  }
-};
-
-jasmine.Queue.prototype.results = function() {
-  var results = new jasmine.NestedResults();
-  for (var i = 0; i < this.blocks.length; i++) {
-    if (this.blocks[i].results) {
-      results.addResult(this.blocks[i].results());
-    }
-  }
-  return results;
-};
-
-
-/**
- * Runner
- *
- * @constructor
- * @param {jasmine.Env} env
- */
-jasmine.Runner = function(env) {
-  var self = this;
-  self.env = env;
-  self.queue = new jasmine.Queue(env);
-  self.before_ = [];
-  self.after_ = [];
-  self.suites_ = [];
-};
-
-jasmine.Runner.prototype.execute = function() {
-  var self = this;
-  if (self.env.reporter.reportRunnerStarting) {
-    self.env.reporter.reportRunnerStarting(this);
-  }
-  self.queue.start(function () {
-    self.finishCallback();
-  });
-};
-
-jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
-  beforeEachFunction.typeName = 'beforeEach';
-  this.before_.splice(0,0,beforeEachFunction);
-};
-
-jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
-  afterEachFunction.typeName = 'afterEach';
-  this.after_.splice(0,0,afterEachFunction);
-};
-
-
-jasmine.Runner.prototype.finishCallback = function() {
-  this.env.reporter.reportRunnerResults(this);
-};
-
-jasmine.Runner.prototype.addSuite = function(suite) {
-  this.suites_.push(suite);
-};
-
-jasmine.Runner.prototype.add = function(block) {
-  if (block instanceof jasmine.Suite) {
-    this.addSuite(block);
-  }
-  this.queue.add(block);
-};
-
-jasmine.Runner.prototype.specs = function () {
-  var suites = this.suites();
-  var specs = [];
-  for (var i = 0; i < suites.length; i++) {
-    specs = specs.concat(suites[i].specs());
-  }
-  return specs;
-};
-
-jasmine.Runner.prototype.suites = function() {
-  return this.suites_;
-};
-
-jasmine.Runner.prototype.topLevelSuites = function() {
-  var topLevelSuites = [];
-  for (var i = 0; i < this.suites_.length; i++) {
-    if (!this.suites_[i].parentSuite) {
-      topLevelSuites.push(this.suites_[i]);
-    }
-  }
-  return topLevelSuites;
-};
-
-jasmine.Runner.prototype.results = function() {
-  return this.queue.results();
-};
-/**
- * Internal representation of a Jasmine specification, or test.
- *
- * @constructor
- * @param {jasmine.Env} env
- * @param {jasmine.Suite} suite
- * @param {String} description
- */
-jasmine.Spec = function(env, suite, description) {
-  if (!env) {
-    throw new Error('jasmine.Env() required');
-  }
-  if (!suite) {
-    throw new Error('jasmine.Suite() required');
-  }
-  var spec = this;
-  spec.id = env.nextSpecId ? env.nextSpecId() : null;
-  spec.env = env;
-  spec.suite = suite;
-  spec.description = description;
-  spec.queue = new jasmine.Queue(env);
-
-  spec.afterCallbacks = [];
-  spec.spies_ = [];
-
-  spec.results_ = new jasmine.NestedResults();
-  spec.results_.description = description;
-  spec.matchersClass = null;
-};
-
-jasmine.Spec.prototype.getFullName = function() {
-  return this.suite.getFullName() + ' ' + this.description + '.';
-};
-
-
-jasmine.Spec.prototype.results = function() {
-  return this.results_;
-};
-
-/**
- * All parameters are pretty-printed and concatenated together, then written to the spec's output.
- *
- * Be careful not to leave calls to jasmine.log in production code.
- */
-jasmine.Spec.prototype.log = function() {
-  return this.results_.log(arguments);
-};
-
-jasmine.Spec.prototype.runs = function (func) {
-  var block = new jasmine.Block(this.env, func, this);
-  this.addToQueue(block);
-  return this;
-};
-
-jasmine.Spec.prototype.addToQueue = function (block) {
-  if (this.queue.isRunning()) {
-    this.queue.insertNext(block);
-  } else {
-    this.queue.add(block);
-  }
-};
-
-/**
- * @param {jasmine.ExpectationResult} result
- */
-jasmine.Spec.prototype.addMatcherResult = function(result) {
-  this.results_.addResult(result);
-};
-
-jasmine.Spec.prototype.expect = function(actual) {
-  var positive = new (this.getMatchersClass_())(this.env, actual, this);
-  positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
-  return positive;
-};
-
-/**
- * Waits a fixed time period before moving to the next block.
- *
- * @deprecated Use waitsFor() instead
- * @param {Number} timeout milliseconds to wait
- */
-jasmine.Spec.prototype.waits = function(timeout) {
-  var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
-  this.addToQueue(waitsFunc);
-  return this;
-};
-
-/**
- * Waits for the latchFunction to return true before proceeding to the next block.
- *
- * @param {Function} latchFunction
- * @param {String} optional_timeoutMessage
- * @param {Number} optional_timeout
- */
-jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
-  var latchFunction_ = null;
-  var optional_timeoutMessage_ = null;
-  var optional_timeout_ = null;
-
-  for (var i = 0; i < arguments.length; i++) {
-    var arg = arguments[i];
-    switch (typeof arg) {
-      case 'function':
-        latchFunction_ = arg;
-        break;
-      case 'string':
-        optional_timeoutMessage_ = arg;
-        break;
-      case 'number':
-        optional_timeout_ = arg;
-        break;
-    }
-  }
-
-  var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this);
-  this.addToQueue(waitsForFunc);
-  return this;
-};
-
-jasmine.Spec.prototype.fail = function (e) {
-  var expectationResult = new jasmine.ExpectationResult({
-    passed: false,
-    message: e ? jasmine.util.formatException(e) : 'Exception',
-    trace: { stack: e.stack }
-  });
-  this.results_.addResult(expectationResult);
-};
-
-jasmine.Spec.prototype.getMatchersClass_ = function() {
-  return this.matchersClass || this.env.matchersClass;
-};
-
-jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
-  var parent = this.getMatchersClass_();
-  var newMatchersClass = function() {
-    parent.apply(this, arguments);
-  };
-  jasmine.util.inherit(newMatchersClass, parent);
-  jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
-  this.matchersClass = newMatchersClass;
-};
-
-jasmine.Spec.prototype.finishCallback = function() {
-  this.env.reporter.reportSpecResults(this);
-};
-
-jasmine.Spec.prototype.finish = function(onComplete) {
-  this.removeAllSpies();
-  this.finishCallback();
-  if (onComplete) {
-    onComplete();
-  }
-};
-
-jasmine.Spec.prototype.after = function(doAfter) {
-  if (this.queue.isRunning()) {
-    this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
-  } else {
-    this.afterCallbacks.unshift(doAfter);
-  }
-};
-
-jasmine.Spec.prototype.execute = function(onComplete) {
-  var spec = this;
-  if (!spec.env.specFilter(spec)) {
-    spec.results_.skipped = true;
-    spec.finish(onComplete);
-    return;
-  }
-
-  this.env.reporter.reportSpecStarting(this);
-
-  spec.env.currentSpec = spec;
-
-  spec.addBeforesAndAftersToQueue();
-
-  spec.queue.start(function () {
-    spec.finish(onComplete);
-  });
-};
-
-jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
-  var runner = this.env.currentRunner();
-  var i;
-
-  for (var suite = this.suite; suite; suite = suite.parentSuite) {
-    for (i = 0; i < suite.before_.length; i++) {
-      this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
-    }
-  }
-  for (i = 0; i < runner.before_.length; i++) {
-    this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
-  }
-  for (i = 0; i < this.afterCallbacks.length; i++) {
-    this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
-  }
-  for (suite = this.suite; suite; suite = suite.parentSuite) {
-    for (i = 0; i < suite.after_.length; i++) {
-      this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
-    }
-  }
-  for (i = 0; i < runner.after_.length; i++) {
-    this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
-  }
-};
-
-jasmine.Spec.prototype.explodes = function() {
-  throw 'explodes function should not have been called';
-};
-
-jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
-  if (obj == jasmine.undefined) {
-    throw "spyOn could not find an object to spy upon for " + methodName + "()";
-  }
-
-  if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
-    throw methodName + '() method does not exist';
-  }
-
-  if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
-    throw new Error(methodName + ' has already been spied upon');
-  }
-
-  var spyObj = jasmine.createSpy(methodName);
-
-  this.spies_.push(spyObj);
-  spyObj.baseObj = obj;
-  spyObj.methodName = methodName;
-  spyObj.originalValue = obj[methodName];
-
-  obj[methodName] = spyObj;
-
-  return spyObj;
-};
-
-jasmine.Spec.prototype.removeAllSpies = function() {
-  for (var i = 0; i < this.spies_.length; i++) {
-    var spy = this.spies_[i];
-    spy.baseObj[spy.methodName] = spy.originalValue;
-  }
-  this.spies_ = [];
-};
-
-/**
- * Internal representation of a Jasmine suite.
- *
- * @constructor
- * @param {jasmine.Env} env
- * @param {String} description
- * @param {Function} specDefinitions
- * @param {jasmine.Suite} parentSuite
- */
-jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
-  var self = this;
-  self.id = env.nextSuiteId ? env.nextSuiteId() : null;
-  self.description = description;
-  self.queue = new jasmine.Queue(env);
-  self.parentSuite = parentSuite;
-  self.env = env;
-  self.before_ = [];
-  self.after_ = [];
-  self.children_ = [];
-  self.suites_ = [];
-  self.specs_ = [];
-};
-
-jasmine.Suite.prototype.getFullName = function() {
-  var fullName = this.description;
-  for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
-    fullName = parentSuite.description + ' ' + fullName;
-  }
-  return fullName;
-};
-
-jasmine.Suite.prototype.finish = function(onComplete) {
-  this.env.reporter.reportSuiteResults(this);
-  this.finished = true;
-  if (typeof(onComplete) == 'function') {
-    onComplete();
-  }
-};
-
-jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
-  beforeEachFunction.typeName = 'beforeEach';
-  this.before_.unshift(beforeEachFunction);
-};
-
-jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
-  afterEachFunction.typeName = 'afterEach';
-  this.after_.unshift(afterEachFunction);
-};
-
-jasmine.Suite.prototype.results = function() {
-  return this.queue.results();
-};
-
-jasmine.Suite.prototype.add = function(suiteOrSpec) {
-  this.children_.push(suiteOrSpec);
-  if (suiteOrSpec instanceof jasmine.Suite) {
-    this.suites_.push(suiteOrSpec);
-    this.env.currentRunner().addSuite(suiteOrSpec);
-  } else {
-    this.specs_.push(suiteOrSpec);
-  }
-  this.queue.add(suiteOrSpec);
-};
-
-jasmine.Suite.prototype.specs = function() {
-  return this.specs_;
-};
-
-jasmine.Suite.prototype.suites = function() {
-  return this.suites_;
-};
-
-jasmine.Suite.prototype.children = function() {
-  return this.children_;
-};
-
-jasmine.Suite.prototype.execute = function(onComplete) {
-  var self = this;
-  this.queue.start(function () {
-    self.finish(onComplete);
-  });
-};
-jasmine.WaitsBlock = function(env, timeout, spec) {
-  this.timeout = timeout;
-  jasmine.Block.call(this, env, null, spec);
-};
-
-jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
-
-jasmine.WaitsBlock.prototype.execute = function (onComplete) {
-  if (jasmine.VERBOSE) {
-    this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
-  }
-  this.env.setTimeout(function () {
-    onComplete();
-  }, this.timeout);
-};
-/**
- * A block which waits for some condition to become true, with timeout.
- *
- * @constructor
- * @extends jasmine.Block
- * @param {jasmine.Env} env The Jasmine environment.
- * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true.
- * @param {Function} latchFunction A function which returns true when the desired condition has been met.
- * @param {String} message The message to display if the desired condition hasn't been met within the given time period.
- * @param {jasmine.Spec} spec The Jasmine spec.
- */
-jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
-  this.timeout = timeout || env.defaultTimeoutInterval;
-  this.latchFunction = latchFunction;
-  this.message = message;
-  this.totalTimeSpentWaitingForLatch = 0;
-  jasmine.Block.call(this, env, null, spec);
-};
-jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
-
-jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
-
-jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
-  if (jasmine.VERBOSE) {
-    this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
-  }
-  var latchFunctionResult;
-  try {
-    latchFunctionResult = this.latchFunction.apply(this.spec);
-  } catch (e) {
-    this.spec.fail(e);
-    onComplete();
-    return;
-  }
-
-  if (latchFunctionResult) {
-    onComplete();
-  } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) {
-    var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen');
-    this.spec.fail({
-      name: 'timeout',
-      message: message
-    });
-
-    this.abort = true;
-    onComplete();
-  } else {
-    this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
-    var self = this;
-    this.env.setTimeout(function() {
-      self.execute(onComplete);
-    }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
-  }
-};
-
-jasmine.version_= {
-  "major": 1,
-  "minor": 3,
-  "build": 1,
-  "revision": 1354556913
-};

From 2484ab19b511143d89834d050f6a62d7c48ec0e2 Mon Sep 17 00:00:00 2001
From: Travis Jeffery 
Date: Sat, 31 Aug 2013 21:03:15 -0500
Subject: [PATCH 17/77] Don't keep the spec runner file after finished running
 tests

---
 Gruntfile.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Gruntfile.js b/Gruntfile.js
index 3fc7ba9c..6ec0e665 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -20,7 +20,6 @@ module.exports = function(grunt) {
       , options: {
           specs: "spec/**/*.js"
         , vendor: "vendor/**/*.js"
-        , keepRunner: true
       }
     }
   })

From 7658da60f8bdb0267d6fc4644d42f39d5dd76eb9 Mon Sep 17 00:00:00 2001
From: Travis Jeffery 
Date: Sat, 31 Aug 2013 21:22:46 -0500
Subject: [PATCH 18/77] Fix lib for jshint

---
 lib/jasmine-jquery.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js
index 9cad20cd..70f9bb10 100644
--- a/lib/jasmine-jquery.js
+++ b/lib/jasmine-jquery.js
@@ -306,7 +306,7 @@ jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
 
 jasmine.JQuery.elementToString = function(element) {
   var domEl = $(element).get(0)
-  if (domEl == undefined || domEl.cloneNode)
+  if (domEl === undefined || domEl.cloneNode)
     return $('
').append($(element).clone()).html() else return element.toString() @@ -474,7 +474,7 @@ jasmine.JQuery.matchersClass = {} toContain: function(selector) { return this.actual.find(selector).length }, - + toBeMatchedBy: function(selector) { return this.actual.filter(selector).length }, @@ -662,7 +662,7 @@ beforeEach(function() { } } return jasmine.undefined - + }) }); From 3ccd200c6dd383bac8faa79f35452eba11d55011 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 21:53:24 -0500 Subject: [PATCH 19/77] Move contributing stuff into its own file --- CONTRIBUTING.md | 28 +++++++++++++ README.md | 105 ++++++++++++++++-------------------------------- 2 files changed, 62 insertions(+), 71 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..f7cc8554 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing to Jasmine-jQuery + +Looking to contribute something to Jasmine-jQuery? **Here's how you can help.** + +## Reporting issues + +We only accept issues that are bug reports or feature requests. Bugs must be isolated and reproducible problems that we can fix within the Jasmine-jQuery. Please read the following guidelines before opening any issue. + +1. **Search for existing issues.** Somemeone else may have reported the same issue. Moreover, the issue may have already been resolved with a fix available. +2. **Create an isolated and reproducible test case.** Be sure the problem exists in Jasmine-jQuery's code with a [reduced test case](http://css-tricks.com/reduced-test-cases/) that should be included in each bug report. +3. **Include a live example.** Make use of jsFiddle or jsBin to share your isolated test cases. +4. **Share as much information as possible.** Include operating system and version, browser and version, version of Jasmine-jQuery. Also include steps to reproduce the bug. + +## Pull requests + +- Try not to pollute your pull request with unintended changes--keep them simple and small +- Please squash your commits when appropriate. This simplifies future cherry picks, and also keeps the git log clean. +- Include tests that fail without your code, and pass with it. +- Update the documentation, examples elsewhere, and the guides: whatever is affected by your contribution. +- If you can, have another developer sanity check your change. + +## Coding standards + +- No semicolons +- Comma first +- 2 spaces (no tabs) +- strict mode +- "Attractive" diff --git a/README.md b/README.md index 8e042ae9..1bda2a7a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # jasmine-jquery jasmine-jquery provides two extensions for [Jasmine](http://pivotal.github.com/jasmine/) JavaScript Testing Framework: - + - a set of custom matchers for jQuery framework - an API for handling HTML, CSS, and JSON fixtures in your specs @@ -20,11 +20,11 @@ jasmine-jquery provides following custom matchers (in alphabetical order): - e.g. `expect($('
')).toBe('div#some-id')` - `toBeChecked()` - only for tags that have checked attribute - - e.g. `expect($('')).toBeChecked()` + - e.g. `expect($('')).toBeChecked()` - `toBeEmpty()` - Checks for child DOM elements or text. - `toBeHidden()` - + Elements can be considered hidden for several reasons: - They have a CSS `display` value of `none`. - They are form elements with `type` equal to `hidden`. @@ -59,7 +59,7 @@ jasmine-jquery provides following custom matchers (in alphabetical order): - `toHaveBeenPrevented()` - if event has been prevented on `selector` (see "Event Spies", below) - `toHaveClass(className)` - - e.g. `expect($('
')).toHaveClass("some-class")` + - e.g. `expect($('
')).toHaveClass("some-class")` - `toHaveData(key, value)` - value is optional, if omitted it will check only if an entry for that key exists - `toHaveHtml(string)` @@ -86,7 +86,7 @@ jasmine-jquery provides following custom matchers (in alphabetical order): - e.g. `expect($form).toHandle("submit")` - `toHandleWith(eventName, eventHandler)` - e.g. `expect($form).toHandleWith("submit", yourSubmitCallback)` - + The same as with standard Jasmine matchers, all of above custom matchers may be inverted by using `.not` prefix, e.g.: expect($('
some text
')).not.toHaveText(/other/) @@ -98,13 +98,13 @@ The Fixture module of jasmine-jquery allows you to load HTML content to be used In _myfixture.html_ file:
some complex content here
- + Inside your test: loadFixtures('myfixture.html'); $('#my-fixture').myTestedPlugin(); expect($('#my-fixture')).to...; - + By default, fixtures are loaded from `spec/javascripts/fixtures`. You can configure this path: `jasmine.getFixtures().fixturesPath = 'my/new/path';`. Your fixture is being loaded into `
` container that is automatically added to the DOM by the Fixture module (If you _REALLY_ must change id of this container, try: `jasmine.getFixtures().containerId = 'my-new-id';` in your test runner). To make tests fully independent, fixtures container is automatically cleaned-up between tests, so you don't have to worry about left-overs from fixtures loaded in preceeding test. Also, fixtures are internally cached by the Fixture module, so you can load the same fixture file in several tests without penalty to your test suite's speed. @@ -112,11 +112,11 @@ Your fixture is being loaded into `
` container To invoke fixture related methods, obtain Fixtures singleton through a factory and invoke a method on it: jasmine.getFixtures().load(...); - + There are also global short cut functions available for the most used methods, so the above example can be rewritten to just: loadFixtures(...); - + Several methods for loading fixtures are provided: - `load(fixtureUrl[, fixtureUrl, ...])` @@ -131,7 +131,7 @@ Several methods for loading fixtures are provided: - Same as set, but adds the fixtures to the pre-existing fixture container. - `preload(fixtureUrl[, fixtureUrl, ...])` - Pre-loads fixture(s) from one or more files and stores them into cache, without returning them or appending them to the DOM. All subsequent calls to `load` or `read` methods will then get fixtures content from cache, without making any AJAX calls (unless cache is manually purged by using `clearCache` method). Pre-loading all fixtures before a test suite is run may be useful when working with libraries like jasmine-ajax that block or otherwise modify the inner workings of JS or jQuery AJAX calls. - + All of above methods have matching global short cuts: - `loadFixtures(fixtureUrl[, fixtureUrl, ...])` @@ -140,7 +140,7 @@ All of above methods have matching global short cuts: - `setFixtures(html)` - `appendSetFixtures(html)` -``` javascript +``` javascript var fixture = setFixture('
foo
') var post = fixture.find('.post') ``` @@ -152,11 +152,11 @@ Also, a helper method for creating HTML elements for your tests is provided: It creates an empty DIV element with a default id="sandbox". If a hash of attributes is provided, they will be set for this DIV tag. If a hash of attributes contains id attribute it will override the default value. Custom attributes can also be set. So e.g.: sandbox(); - + Will return: -
- +
+ And: sandbox({ @@ -164,7 +164,7 @@ And: class: 'my-class', myattr: 'my-attr' }); - + Will return:
@@ -185,7 +185,7 @@ Additionally, two clean up methods are provided: - purges Fixture module internal cache (you should need it only in very special cases; typically, if you need to use it, it may indicate a smell in your test code) - `cleanUp()` - cleans-up fixtures container (this is done automatically between tests by Fixtures module, so there is no need to ever invoke this manually, unless you're testing a really fancy special case and need to clean-up fixtures in the middle of your test) - + These two methods do not have global short cut functions. ## Style Fixtures @@ -195,7 +195,7 @@ The StyleFixtures module is pretty much like the Fixtures module, but it allows In _mycssfixture.css_ file: .elem { position: absolute } - + Inside your test: loadStyleFixtures('mycssfixture.css'); @@ -203,7 +203,7 @@ Inside your test: expect($('#my-fixture .elem')).toHaveCss({left: "300px"}); Notice that if you haven't applied the `position: absolute` rule to the `.elem` and try to test its left position in some browsers (e.g. GoogleChrome) you will allways get the value `auto` even if your plugin did everything correct and applied positioning. So that's why you might need to load style fixtures. In Firefox though you will get the correct value even without the `position: absolute`. - + By default, style fixtures are loaded from `spec/javascripts/fixtures`. You can configure this path: `jasmine.getStyleFixtures().fixturesPath = 'my/new/path';`. Like in Fixtures module, StyleFixtures are also automatically cleaned-up between tests and are internally cached, so you can load the same fixture file in several tests without penalty to your test suite's speed. @@ -211,11 +211,11 @@ Like in Fixtures module, StyleFixtures are also automatically cleaned-up between To invoke fixture related methods, obtain StyleFixtures singleton through a factory and invoke a method on it: jasmine.getStyleFixtures().load(...); - + There are also global short cut functions available for the most used methods, so the above example can be rewritten to just: loadStyleFixtures(...); - + Several methods for loading fixtures are provided: - `load(fixtureUrl[, fixtureUrl, ...])` @@ -228,13 +228,13 @@ Several methods for loading fixtures are provided: - Same as set, but it won't remove fixtures you added earlier. - `preload(fixtureUrl[, fixtureUrl, ...])` - Pre-loads fixture(s) from one or more files and stores them into cache, without returning them or appending them to the DOM. All subsequent calls to `load` methods will then get fixtures content from cache, without making any AJAX calls (unless cache is manually purged by using `clearCache` method). - + All of above methods have matching global short cuts: - `loadStyleFixtures(fixtureUrl[, fixtureUrl, ...])` - `appendLoadStyleFixtures(fixtureUrl[, fixtureUrl, ...])` - `setStyleFixtures(css)` -- `appendSetStyleFixtures(css)` +- `appendSetStyleFixtures(css)` Additionally, two clean up methods are provided: @@ -242,45 +242,45 @@ Additionally, two clean up methods are provided: - purges StyleFixture module internal cache (you should need it only in very special cases; typically, if you need to use it, it may indicate a smell in your test code) - `cleanUp()` - cleans-up all existing style fixtures (this is done automatically between tests, so there is no need to ever invoke this manually, unless you're testing a really fancy special case and need to clean-up fixtures in the middle of your test) - + These two methods do not have global short cut functions. ## JSON Fixtures -The JSONFixtures modules allows you to load JSON data from file (instead of putting huge blocks of data in the spec files). +The JSONFixtures modules allows you to load JSON data from file (instead of putting huge blocks of data in the spec files). In _myjsonfixture.json_ file: {"property1":"value1", "array1":[1,2,3]} - + Inside your test: var data = getJSONFixture('myjsonfixture.json'); // or load and get the JSON two-step var fixtures = loadJSONFixtures('myjsonfixture.json'); var data = fixtures['myjsonfixture.json']; - + expect(myDataManipulator.processData(test_data)).to...) - + By default, fixtures are loaded from `spec/javascripts/fixtures/json`. You can configure this path: `jasmine.getJSONFixtures().fixturesPath = 'my/new/path';`. -Your fixture data is loaded into an object stashed by the JSONFixtures structure. You fetch the data using the filename as the key. This allows you to load multiple chunks of test data in a spec. +Your fixture data is loaded into an object stashed by the JSONFixtures structure. You fetch the data using the filename as the key. This allows you to load multiple chunks of test data in a spec. Because a deep copy of Javascript objects can be a little tricky, this module will refetch data each time you call `load`. If you modify the data within a spec, you must call `load` or `loadJSONFixtures` again to repopulate the data. To invoke fixture related methods, obtain Fixtures singleton through a factory and invoke a method on it: jasmine.getJSONFixtures().load(...); - + There are also global short cut functions available for the most used methods, so the above example can be rewritten to just: loadJSONFixtures(...); - + Several methods for loading fixtures are provided: - `load(fixtureUrl[, fixtureUrl, ...])` - Loads fixture(s) from one or more files and automatically adds them to the fixture list. This method returns the entire set of fixtures keyed by their filename. - + All of above methods have matching global short cuts: - `loadJSONFixtures(fixtureUrl[, fixtureUrl, ...])` @@ -348,45 +348,8 @@ Under Windows 7, you have to launch `C:\Users\[UserName]\AppData\Local\Google\Ch When using [jstd](http://code.google.com/p/js-test-driver/) and the jasmine adapter you will need to include jasmine-jquery.js after your jasmine-jstd-adapter files, otherwise jasmine-jquery matchers will not be available when tests are executed. Check out [this issue](/~https://github.com/velesin/jasmine-jquery/issues/95#issuecomment-9293180) for a thorough configuration example too. -## Contributing - -jasmine-jquery is maintained by [Travis Jeffery](http://github.com/travisjeffery). - -### Setup - -- Fork the project and clone the repository. - - [Here's how.](http://help.github.com/fork-a-repo/) -- Create a dedicated branch. - - `git checkout -b your_feature` - -### Writing the Code - -- Get the code right. -- Include tests that fail without your code, and pass with it. -- Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution. -- Follow the conventions in the source you see used already, basically [npm coding style](http://npmjs.org/doc/coding-style.html) - -If you can, have another developer sanity check your change. - -### Committing - -- Commit your change with a message on what you changed in the commit. - - `git commit -am "A commit message on what you changed"` -- Please squash your commits when appropriate. This simplifies future cherry picks, and also keeps the git log clean. - - [Here's how.](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) -- Push to your remote - - `git push origin your_feature` - -### Issue a Pull Request +## Maintainer -- Navigate to the jasmine-jquery GitHub page, press "Pull Request". -- Write your branch name in the branch field, press "Update Commit Range". -- Fill in some details about your potential patch including a meaningful - title. When finished, press "Send pull request". +[Travis Jeffery](http://travisjeffery.com/): [Twitter](http://twitter.com/travisjeffery), [GitHub](http://github.com/travisjeffery). -(These guidelines are heavily inspired and similar to [Rails's](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-code)). +## [Contributing](./blob/master/CONTRIBUTING.md) \ No newline at end of file From 47b6a0bafc2460b00fb45d66d093ab1581d4c6cd Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 21:55:34 -0500 Subject: [PATCH 20/77] Fix path to contributing file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1bda2a7a..0f248c94 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ jasmine-jquery provides two extensions for [Jasmine](http://pivotal.github.com/j Simply download _jasmine-jquery.js_ from [here](https://raw.github.com/velesin/jasmine-jquery/master/lib/jasmine-jquery.js) and include it in your Jasmine's test runner file (or add it to _jasmine.yml_ file if you're using Ruby with [jasmine-gem](http://github.com/pivotal/jasmine-gem)). Remember to include also jQuery library as jasmine-jquery relies on it. -For Ruby on Rails I recommend to comply with the standard RSpec and Jasmine frameworks dir structure and keep your tests in `spec/javascripts/` dir. I put jasmine-jquery (and other libraries like jasmine-ajax) into `spec/javascripts/helpers` dir (so they are automatically loaded) and fixtures into `spec/javascripts/fixtures` dir. +For Ruby on Rails, use this [gem](/~https://github.com/travisjeffery/jasmine-jquery-rails) or I recommend to comply with the standard RSpec and Jasmine frameworks dir structure and keep your tests in `spec/javascripts/` dir. I put jasmine-jquery (and other libraries like jasmine-ajax) into `spec/javascripts/helpers` dir (so they are automatically loaded) and fixtures into `spec/javascripts/fixtures` dir. ## jQuery matchers @@ -352,4 +352,4 @@ When using [jstd](http://code.google.com/p/js-test-driver/) and the jasmine adap [Travis Jeffery](http://travisjeffery.com/): [Twitter](http://twitter.com/travisjeffery), [GitHub](http://github.com/travisjeffery). -## [Contributing](./blob/master/CONTRIBUTING.md) \ No newline at end of file +## [Contributing](./CONTRIBUTING.md) \ No newline at end of file From cc80985d313ed9b5d682ea6d682d9ac8bf36894a Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 22:09:12 -0500 Subject: [PATCH 21/77] Use glob to find lib --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6ec0e665..9728d57f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,7 +8,7 @@ module.exports = function(grunt) { , jshint: { all: [ "Gruntfile.js" - , "lib/*.js" + , "lib/**/*.js" , "spec/**/*.js" ] , options: { From 3f86aaafb497aa8a53272132fa385463e22db7f1 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 22:09:25 -0500 Subject: [PATCH 22/77] Add travis-ci --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..b30fcb75 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.8 +before_script: + - npm install -g grunt-cli From f489b8335deba9c132de3811e348e7efde21d21b Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 23:36:20 -0500 Subject: [PATCH 23/77] Add issues-guidelines.js --- .issues-guidelines.js | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .issues-guidelines.js diff --git a/.issues-guidelines.js b/.issues-guidelines.js new file mode 100644 index 00000000..aade7e66 --- /dev/null +++ b/.issues-guidelines.js @@ -0,0 +1,60 @@ +var assert = require('assert'); + +module.exports = { + + 'pull-requests': { + + 'should always be made against -wip branches': function (pull) { + assert.ok(/\-wip$/.test(pull.base.ref)) + }, + + 'should always be made from feature branches': function (pull) { + assert.notEqual(pull.head.ref, 'master') + }, + + 'should always include a unit test if changing js files': function (pull) { + var hasJS = false + var hasTests = false + + pull.files.forEach(function (file) { + if (/^lib\/[^./]+.js/.test(file.filename)) hasJS = true + if (/^spec\/suites\/[^.]+.js/.test(file.filename)) hasTests = true + }) + + assert.ok(!hasJS || hasJS && hasTests) + }, + + 'after': function (pull) { + if (pull.reporter.stats.failures) { + pull.reportFailures(pull.close.bind(pull)) + } + } + + }, + + 'issues': { + + 'before': function (issue) { + var plus = {} + + issue.comments.forEach(function (comment) { + if (/\+1/.test(comment.body)) plus[comment.user.login] = true + }) + + if (Object.keys(plus) > 10) issue.tag('popular') + }, + + 'should include a jsfiddle/jsbin illustrating the problem if tagged with js but not a feature': function (issue) { + var labels = issue.labels.map(function (label) { return label.name }); + if (~labels.indexOf('js') && !~labels.indexOf('feature')) assert.ok(/(jsfiddle|jsbin)/.test(issue.body)) + }, + + 'after': function (issue) { + if (issue.reporter.stats.failures) { + issue.reportFailures(issue.close.bind(issue)) + } + } + + } + +} \ No newline at end of file From 596e6ff4238621f98247f305e274fb7e3b9d3953 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 23:44:07 -0500 Subject: [PATCH 24/77] Pass in jasmine, jquery --- lib/jasmine-jquery.js | 709 +++++++++++++++++++++--------------------- 1 file changed, 356 insertions(+), 353 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 70f9bb10..78c1e018 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -25,369 +25,371 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -var readFixtures = function() { - return jasmine.getFixtures().proxyCallTo_('read', arguments) -} - -var preloadFixtures = function() { - jasmine.getFixtures().proxyCallTo_('preload', arguments) -} + */ -var loadFixtures = function() { - jasmine.getFixtures().proxyCallTo_('load', arguments) -} + +function (jasmine, $, global) { "use strict"; + global.readFixtures = function() { + return jasmine.getFixtures().proxyCallTo_('read', arguments) + } -var appendLoadFixtures = function() { - jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) -} + global.preloadFixtures = function() { + jasmine.getFixtures().proxyCallTo_('preload', arguments) + } -var setFixtures = function(html) { - return jasmine.getFixtures().proxyCallTo_('set', arguments) -} + global.loadFixtures = function() { + jasmine.getFixtures().proxyCallTo_('load', arguments) + } -var appendSetFixtures = function() { - jasmine.getFixtures().proxyCallTo_('appendSet', arguments) -} + global.appendLoadFixtures = function() { + jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) + } -var sandbox = function(attributes) { - return jasmine.getFixtures().sandbox(attributes) -} + global.setFixtures = function(html) { + return jasmine.getFixtures().proxyCallTo_('set', arguments) + } -var spyOnEvent = function(selector, eventName) { - return jasmine.JQuery.events.spyOn(selector, eventName) -} + global.appendSetFixtures = function() { + jasmine.getFixtures().proxyCallTo_('appendSet', arguments) + } -var preloadStyleFixtures = function() { - jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) -} + global.sandbox = function(attributes) { + return jasmine.getFixtures().sandbox(attributes) + } -var loadStyleFixtures = function() { - jasmine.getStyleFixtures().proxyCallTo_('load', arguments) -} + global.spyOnEvent = function(selector, eventName) { + return jasmine.JQuery.events.spyOn(selector, eventName) + } -var appendLoadStyleFixtures = function() { - jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) -} + global.preloadStyleFixtures = function() { + jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) + } -var setStyleFixtures = function(html) { - jasmine.getStyleFixtures().proxyCallTo_('set', arguments) -} + global.loadStyleFixtures = function() { + jasmine.getStyleFixtures().proxyCallTo_('load', arguments) + } -var appendSetStyleFixtures = function(html) { - jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) -} + global.appendLoadStyleFixtures = function() { + jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) + } -var loadJSONFixtures = function() { - return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) -} + global.setStyleFixtures = function(html) { + jasmine.getStyleFixtures().proxyCallTo_('set', arguments) + } -var getJSONFixture = function(url) { - return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] -} + global.appendSetStyleFixtures = function(html) { + jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) + } -jasmine.spiedEventsKey = function (selector, eventName) { - return [$(selector).selector, eventName].toString() -} + global.loadJSONFixtures = function() { + return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) + } -jasmine.getFixtures = function() { - return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures() -} + global.getJSONFixture = function(url) { + return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] + } -jasmine.getStyleFixtures = function() { - return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures() -} + jasmine.spiedEventsKey = function (selector, eventName) { + return [$(selector).selector, eventName].toString() + } -jasmine.Fixtures = function() { - this.containerId = 'jasmine-fixtures' - this.fixturesCache_ = {} - this.fixturesPath = 'spec/javascripts/fixtures' -} + jasmine.getFixtures = function() { + return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures() + } -jasmine.Fixtures.prototype.set = function(html) { - this.cleanUp() - return this.createContainer_(html) -} + jasmine.getStyleFixtures = function() { + return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures() + } -jasmine.Fixtures.prototype.appendSet= function(html) { - this.addToContainer_(html) -} + jasmine.Fixtures = function() { + this.containerId = 'jasmine-fixtures' + this.fixturesCache_ = {} + this.fixturesPath = 'spec/javascripts/fixtures' + } -jasmine.Fixtures.prototype.preload = function() { - this.read.apply(this, arguments) -} + jasmine.Fixtures.prototype.set = function(html) { + this.cleanUp() + return this.createContainer_(html) + } -jasmine.Fixtures.prototype.load = function() { - this.cleanUp() - this.createContainer_(this.read.apply(this, arguments)) -} + jasmine.Fixtures.prototype.appendSet= function(html) { + this.addToContainer_(html) + } -jasmine.Fixtures.prototype.appendLoad = function() { - this.addToContainer_(this.read.apply(this, arguments)) -} + jasmine.Fixtures.prototype.preload = function() { + this.read.apply(this, arguments) + } -jasmine.Fixtures.prototype.read = function() { - var htmlChunks = [] + jasmine.Fixtures.prototype.load = function() { + this.cleanUp() + this.createContainer_(this.read.apply(this, arguments)) + } - var fixtureUrls = arguments - for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { - htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) + jasmine.Fixtures.prototype.appendLoad = function() { + this.addToContainer_(this.read.apply(this, arguments)) } - return htmlChunks.join('') -} + jasmine.Fixtures.prototype.read = function() { + var htmlChunks = [] -jasmine.Fixtures.prototype.clearCache = function() { - this.fixturesCache_ = {} -} + var fixtureUrls = arguments + for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { + htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) + } + + return htmlChunks.join('') + } -jasmine.Fixtures.prototype.cleanUp = function() { - $('#' + this.containerId).remove() -} + jasmine.Fixtures.prototype.clearCache = function() { + this.fixturesCache_ = {} + } -jasmine.Fixtures.prototype.sandbox = function(attributes) { - var attributesToSet = attributes || {} - return $('
').attr(attributesToSet) -} + jasmine.Fixtures.prototype.cleanUp = function() { + $('#' + this.containerId).remove() + } + + jasmine.Fixtures.prototype.sandbox = function(attributes) { + var attributesToSet = attributes || {} + return $('
').attr(attributesToSet) + } -jasmine.Fixtures.prototype.createContainer_ = function(html) { - var container = $('
') + jasmine.Fixtures.prototype.createContainer_ = function(html) { + var container = $('
') .attr('id', this.containerId) .html(html) - $(document.body).append(container) - return container -} + $(document.body).append(container) + return container + } -jasmine.Fixtures.prototype.addToContainer_ = function(html){ - var container = $(document.body).find('#'+this.containerId).append(html) - if(!container.length){ - this.createContainer_(html) + jasmine.Fixtures.prototype.addToContainer_ = function(html){ + var container = $(document.body).find('#'+this.containerId).append(html) + if(!container.length){ + this.createContainer_(html) + } } -} -jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) { - if (typeof this.fixturesCache_[url] === 'undefined') { - this.loadFixtureIntoCache_(url) + jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) { + if (typeof this.fixturesCache_[url] === 'undefined') { + this.loadFixtureIntoCache_(url) + } + return this.fixturesCache_[url] } - return this.fixturesCache_[url] -} -jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) { - var url = this.makeFixtureUrl_(relativeUrl) - var request = $.ajax({ - type: "GET", - url: url + "?" + new Date().getTime(), - async: false - }) - this.fixturesCache_[relativeUrl] = request.responseText -} + jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) { + var url = this.makeFixtureUrl_(relativeUrl) + var request = $.ajax({ + type: "GET", + url: url + "?" + new Date().getTime(), + async: false + }) + this.fixturesCache_[relativeUrl] = request.responseText + } -jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){ - return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl -} + jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){ + return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl + } -jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) { - return this[methodName].apply(this, passedArguments) -} + jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) { + return this[methodName].apply(this, passedArguments) + } -jasmine.StyleFixtures = function() { - this.fixturesCache_ = {} - this.fixturesNodes_ = [] - this.fixturesPath = 'spec/javascripts/fixtures' -} + jasmine.StyleFixtures = function() { + this.fixturesCache_ = {} + this.fixturesNodes_ = [] + this.fixturesPath = 'spec/javascripts/fixtures' + } -jasmine.StyleFixtures.prototype.set = function(css) { - this.cleanUp() - this.createStyle_(css) -} + jasmine.StyleFixtures.prototype.set = function(css) { + this.cleanUp() + this.createStyle_(css) + } -jasmine.StyleFixtures.prototype.appendSet = function(css) { - this.createStyle_(css) -} + jasmine.StyleFixtures.prototype.appendSet = function(css) { + this.createStyle_(css) + } -jasmine.StyleFixtures.prototype.preload = function() { - this.read_.apply(this, arguments) -} + jasmine.StyleFixtures.prototype.preload = function() { + this.read_.apply(this, arguments) + } -jasmine.StyleFixtures.prototype.load = function() { - this.cleanUp() - this.createStyle_(this.read_.apply(this, arguments)) -} + jasmine.StyleFixtures.prototype.load = function() { + this.cleanUp() + this.createStyle_(this.read_.apply(this, arguments)) + } -jasmine.StyleFixtures.prototype.appendLoad = function() { - this.createStyle_(this.read_.apply(this, arguments)) -} + jasmine.StyleFixtures.prototype.appendLoad = function() { + this.createStyle_(this.read_.apply(this, arguments)) + } -jasmine.StyleFixtures.prototype.cleanUp = function() { - while(this.fixturesNodes_.length) { - this.fixturesNodes_.pop().remove() + jasmine.StyleFixtures.prototype.cleanUp = function() { + while(this.fixturesNodes_.length) { + this.fixturesNodes_.pop().remove() + } } -} -jasmine.StyleFixtures.prototype.createStyle_ = function(html) { - var styleText = $('
').html(html).text(), + jasmine.StyleFixtures.prototype.createStyle_ = function(html) { + var styleText = $('
').html(html).text(), style = $('') - this.fixturesNodes_.push(style) + this.fixturesNodes_.push(style) - $('head').append(style) -} - -jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache - -jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read - -jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_ + $('head').append(style) + } -jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_ + jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache -jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_ + jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read -jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ + jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_ -jasmine.getJSONFixtures = function() { - return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures() -} + jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_ -jasmine.JSONFixtures = function() { - this.fixturesCache_ = {} - this.fixturesPath = 'spec/javascripts/fixtures/json' -} + jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_ -jasmine.JSONFixtures.prototype.load = function() { - this.read.apply(this, arguments) - return this.fixturesCache_ -} + jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ -jasmine.JSONFixtures.prototype.read = function() { - var fixtureUrls = arguments - for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { - this.getFixtureData_(fixtureUrls[urlIndex]) + jasmine.getJSONFixtures = function() { + return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures() } - return this.fixturesCache_ -} -jasmine.JSONFixtures.prototype.clearCache = function() { - this.fixturesCache_ = {} -} + jasmine.JSONFixtures = function() { + this.fixturesCache_ = {} + this.fixturesPath = 'spec/javascripts/fixtures/json' + } -jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) { - this.loadFixtureIntoCache_(url) - return this.fixturesCache_[url] -} + jasmine.JSONFixtures.prototype.load = function() { + this.read.apply(this, arguments) + return this.fixturesCache_ + } -jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) { - var self = this - var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl - $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - dataType: 'json', - url: url, - success: function(data) { - self.fixturesCache_[relativeUrl] = data - }, - error: function(jqXHR, status, errorThrown) { - throw Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + jasmine.JSONFixtures.prototype.read = function() { + var fixtureUrls = arguments + for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { + this.getFixtureData_(fixtureUrls[urlIndex]) } - }) -} + return this.fixturesCache_ + } -jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) { - return this[methodName].apply(this, passedArguments) -} + jasmine.JSONFixtures.prototype.clearCache = function() { + this.fixturesCache_ = {} + } -jasmine.JQuery = function() {} + jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) { + this.loadFixtureIntoCache_(url) + return this.fixturesCache_[url] + } -jasmine.JQuery.browserTagCaseIndependentHtml = function(html) { - return $('
').append(html).html() -} + jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) { + var self = this + var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl + $.ajax({ + async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded + cache: false, + dataType: 'json', + url: url, + success: function(data) { + self.fixturesCache_[relativeUrl] = data + }, + error: function(jqXHR, status, errorThrown) { + throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + } + }) + } -jasmine.JQuery.elementToString = function(element) { - var domEl = $(element).get(0) - if (domEl === undefined || domEl.cloneNode) - return $('
').append($(element).clone()).html() - else - return element.toString() -} + jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) { + return this[methodName].apply(this, passedArguments) + } -jasmine.JQuery.matchersClass = {} + jasmine.JQuery = function() {} -!function(namespace) { - var data = { - spiedEvents: {}, - handlers: [] + jasmine.JQuery.browserTagCaseIndependentHtml = function(html) { + return $('
').append(html).html() } - namespace.events = { - spyOn: function(selector, eventName) { - var handler = function(e) { - data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) - } - $(selector).on(eventName, handler) - data.handlers.push(handler) - return { - selector: selector, - eventName: eventName, - handler: handler, - reset: function(){ - delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - } - } - }, + jasmine.JQuery.elementToString = function(element) { + var domEl = $(element).get(0) + if (domEl === undefined || domEl.cloneNode) + return $('
').append($(element).clone()).html() + else + return element.toString() + } - args: function(selector, eventName) { - var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + jasmine.JQuery.matchersClass = {} - if (!actualArgs) { - throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." - } + !function(namespace) { + var data = { + spiedEvents: {}, + handlers: [] + } - return actualArgs - }, + namespace.events = { + spyOn: function(selector, eventName) { + var handler = function(e) { + data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) + } + $(selector).on(eventName, handler) + data.handlers.push(handler) + return { + selector: selector, + eventName: eventName, + handler: handler, + reset: function(){ + delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + } + } + }, - wasTriggered: function(selector, eventName) { - return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) - }, + args: function(selector, eventName) { + var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - wasTriggeredWith: function(selector, eventName, expectedArgs, env) { - var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1) - if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { - actualArgs = actualArgs[0] - } - return env.equals_(expectedArgs, actualArgs) - }, + if (!actualArgs) { + throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." + } - wasPrevented: function(selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], - e = args ? args[0] : undefined - return e && e.isDefaultPrevented() - }, + return actualArgs + }, - wasStopped: function(selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], - e = args ? args[0] : undefined - return e && e.isPropagationStopped() - }, + wasTriggered: function(selector, eventName) { + return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) + }, - cleanUp: function() { - data.spiedEvents = {} - data.handlers = [] + wasTriggeredWith: function(selector, eventName, expectedArgs, env) { + var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1) + if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { + actualArgs = actualArgs[0] + } + return env.equals_(expectedArgs, actualArgs) + }, + + wasPrevented: function(selector, eventName) { + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], + e = args ? args[0] : undefined + return e && e.isDefaultPrevented() + }, + + wasStopped: function(selector, eventName) { + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], + e = args ? args[0] : undefined + return e && e.isPropagationStopped() + }, + + cleanUp: function() { + data.spiedEvents = {} + data.handlers = [] + } } - } -}(jasmine.JQuery); + }(jasmine.JQuery); -!function(){ - var jQueryMatchers = { - toHaveClass: function(className) { - return this.actual.hasClass(className) - }, + !function(){ + var jQueryMatchers = { + toHaveClass: function(className) { + return this.actual.hasClass(className) + }, - toHaveCss: function(css){ - for (var prop in css){ - if (this.actual.css(prop) !== css[prop]) return false - } + toHaveCss: function(css){ + for (var prop in css){ + if (this.actual.css(prop) !== css[prop]) return false + } return true }, @@ -512,20 +514,20 @@ jasmine.JQuery.matchersClass = {} } }, - // tests the existence of a specific event binding + handler - toHandleWith: function(eventName, eventHandler) { - var normalizedEventName = eventName.split('.')[0] - var stack = $._data(this.actual.get(0), "events")[normalizedEventName] - for (var i = 0; i < stack.length; i++) { - if (stack[i].handler == eventHandler) return true - } + // tests the existence of a specific event binding + handler + toHandleWith: function(eventName, eventHandler) { + var normalizedEventName = eventName.split('.')[0] + var stack = $._data(this.actual.get(0), "events")[normalizedEventName] + for (var i = 0; i < stack.length; i++) { + if (stack[i].handler == eventHandler) return true + } return false } } var hasProperty = function(actualValue, expectedValue) { if (expectedValue === undefined) return actualValue !== undefined - return actualValue == expectedValue + return actualValue == expectedValue } var bindMatcher = function(methodName) { @@ -535,81 +537,81 @@ jasmine.JQuery.matchersClass = {} if (this.actual && (this.actual instanceof $ || jasmine.isDomNode(this.actual))) { - this.actual = $(this.actual) - var result = jQueryMatchers[methodName].apply(this, arguments) - var element - if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") - this.actual = jasmine.JQuery.elementToString(this.actual) - return result - } - - if (builtInMatcher) { - return builtInMatcher.apply(this, arguments) - } + this.actual = $(this.actual) + var result = jQueryMatchers[methodName].apply(this, arguments) + var element + if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") + this.actual = jasmine.JQuery.elementToString(this.actual) + return result + } - return false + if (builtInMatcher) { + return builtInMatcher.apply(this, arguments) } + + return false + } } for(var methodName in jQueryMatchers) { bindMatcher(methodName) } -}() + }() -beforeEach(function() { - this.addMatchers(jasmine.JQuery.matchersClass) - this.addMatchers({ - toHaveBeenTriggeredOn: function(selector) { - this.message = function() { - return [ + beforeEach(function() { + this.addMatchers(jasmine.JQuery.matchersClass) + this.addMatchers({ + toHaveBeenTriggeredOn: function(selector) { + this.message = function() { + return [ "Expected event " + this.actual + " to have been triggered on " + selector, "Expected event " + this.actual + " not to have been triggered on " + selector - ] + ] + } + return jasmine.JQuery.events.wasTriggered(selector, this.actual) } - return jasmine.JQuery.events.wasTriggered(selector, this.actual) - } - }) - this.addMatchers({ - toHaveBeenTriggered: function(){ - var eventName = this.actual.eventName, - selector = this.actual.selector - this.message = function() { - return [ + }) + this.addMatchers({ + toHaveBeenTriggered: function(){ + var eventName = this.actual.eventName, + selector = this.actual.selector + this.message = function() { + return [ "Expected event " + eventName + " to have been triggered on " + selector, "Expected event " + eventName + " not to have been triggered on " + selector - ] + ] + } + return jasmine.JQuery.events.wasTriggered(selector, eventName) } - return jasmine.JQuery.events.wasTriggered(selector, eventName) - } - }) - this.addMatchers({ - toHaveBeenTriggeredOnAndWith: function() { - var selector = arguments[0], - expectedArgs = arguments[1], - wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) - this.message = function() { - if (wasTriggered) { - var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] - return [ + }) + this.addMatchers({ + toHaveBeenTriggeredOnAndWith: function() { + var selector = arguments[0], + expectedArgs = arguments[1], + wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) + this.message = function() { + if (wasTriggered) { + var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] + return [ "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) - ] - } else { - return [ + ] + } else { + return [ "Expected event " + this.actual + " to have been triggered on " + selector, "Expected event " + this.actual + " not to have been triggered on " + selector - ] + ] + } } + return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) } - return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) - } - }) + }) this.addMatchers({ toHaveBeenPreventedOn: function(selector) { this.message = function() { return [ - "Expected event " + this.actual + " to have been prevented on " + selector, - "Expected event " + this.actual + " not to have been prevented on " + selector + "Expected event " + this.actual + " to have been prevented on " + selector, + "Expected event " + this.actual + " not to have been prevented on " + selector ] } return jasmine.JQuery.events.wasPrevented(selector, this.actual) @@ -618,11 +620,11 @@ beforeEach(function() { this.addMatchers({ toHaveBeenPrevented: function() { var eventName = this.actual.eventName, - selector = this.actual.selector + selector = this.actual.selector this.message = function() { return [ - "Expected event " + eventName + " to have been prevented on " + selector, - "Expected event " + eventName + " not to have been prevented on " + selector + "Expected event " + eventName + " to have been prevented on " + selector, + "Expected event " + eventName + " not to have been prevented on " + selector ] } return jasmine.JQuery.events.wasPrevented(selector, eventName) @@ -632,8 +634,8 @@ beforeEach(function() { toHaveBeenStoppedOn: function(selector) { this.message = function() { return [ - "Expected event " + this.actual + " to have been stopped on " + selector, - "Expected event " + this.actual + " not to have been stopped on " + selector + "Expected event " + this.actual + " to have been stopped on " + selector, + "Expected event " + this.actual + " not to have been stopped on " + selector ] } return jasmine.JQuery.events.wasStopped(selector, this.actual) @@ -642,11 +644,11 @@ beforeEach(function() { this.addMatchers({ toHaveBeenStopped: function() { var eventName = this.actual.eventName, - selector = this.actual.selector + selector = this.actual.selector this.message = function() { return [ - "Expected event " + eventName + " to have been stopped on " + selector, - "Expected event " + eventName + " not to have been stopped on " + selector + "Expected event " + eventName + " to have been stopped on " + selector, + "Expected event " + eventName + " not to have been stopped on " + selector ] } return jasmine.JQuery.events.wasStopped(selector, eventName) @@ -664,10 +666,11 @@ beforeEach(function() { return jasmine.undefined }) -}); + }) -afterEach(function() { - jasmine.getFixtures().cleanUp() - jasmine.getStyleFixtures().cleanUp() - jasmine.JQuery.events.cleanUp() -}); + afterEach(function() { + jasmine.getFixtures().cleanUp() + jasmine.getStyleFixtures().cleanUp() + jasmine.JQuery.events.cleanUp() + }) +}(window.jasmine, window.jQuery, window); \ No newline at end of file From 6d831ace6e04c6bb13cd85fed877498cad212355 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 31 Aug 2013 23:49:22 -0500 Subject: [PATCH 25/77] Style --- Gruntfile.js | 2 +- README.md | 82 +-- lib/jasmine-jquery.js | 222 ++++---- spec/suites/jasmine-jquery-spec.js | 806 ++++++++++++++--------------- 4 files changed, 556 insertions(+), 556 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9728d57f..5c64b54d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,6 @@ /* jshint node: true */ -module.exports = function(grunt) { +module.exports = function (grunt) { "use strict"; grunt.initConfig({ diff --git a/README.md b/README.md index 0f248c94..8b3266cc 100644 --- a/README.md +++ b/README.md @@ -101,9 +101,9 @@ In _myfixture.html_ file: Inside your test: - loadFixtures('myfixture.html'); - $('#my-fixture').myTestedPlugin(); - expect($('#my-fixture')).to...; + loadFixtures('myfixture.html') + $('#my-fixture').myTestedPlugin() + expect($('#my-fixture')).to... By default, fixtures are loaded from `spec/javascripts/fixtures`. You can configure this path: `jasmine.getFixtures().fixturesPath = 'my/new/path';`. @@ -111,11 +111,11 @@ Your fixture is being loaded into `
` container To invoke fixture related methods, obtain Fixtures singleton through a factory and invoke a method on it: - jasmine.getFixtures().load(...); + jasmine.getFixtures().load(...) There are also global short cut functions available for the most used methods, so the above example can be rewritten to just: - loadFixtures(...); + loadFixtures(...) Several methods for loading fixtures are provided: @@ -151,7 +151,7 @@ Also, a helper method for creating HTML elements for your tests is provided: It creates an empty DIV element with a default id="sandbox". If a hash of attributes is provided, they will be set for this DIV tag. If a hash of attributes contains id attribute it will override the default value. Custom attributes can also be set. So e.g.: - sandbox(); + sandbox() Will return: @@ -163,7 +163,7 @@ And: id: 'my-id', class: 'my-class', myattr: 'my-attr' - }); + }) Will return: @@ -171,9 +171,9 @@ Will return: Sandbox method is useful if you want to quickly create simple fixtures in your tests without polluting them with HTML strings: - setFixtures(sandbox({class: 'my-class'})); - $('#sandbox').myTestedClassRemoverPlugin(); - expect($('#sandbox')).not.toHaveClass('my-class'); + setFixtures(sandbox({class: 'my-class'})) + $('#sandbox').myTestedClassRemoverPlugin() + expect($('#sandbox')).not.toHaveClass('my-class') This method also has a global short cut available: @@ -198,9 +198,9 @@ In _mycssfixture.css_ file: Inside your test: - loadStyleFixtures('mycssfixture.css'); - $('#my-fixture').myTestedPlugin(); - expect($('#my-fixture .elem')).toHaveCss({left: "300px"}); + loadStyleFixtures('mycssfixture.css') + $('#my-fixture').myTestedPlugin() + expect($('#my-fixture .elem')).toHaveCss({left: "300px"}) Notice that if you haven't applied the `position: absolute` rule to the `.elem` and try to test its left position in some browsers (e.g. GoogleChrome) you will allways get the value `auto` even if your plugin did everything correct and applied positioning. So that's why you might need to load style fixtures. In Firefox though you will get the correct value even without the `position: absolute`. @@ -210,11 +210,11 @@ Like in Fixtures module, StyleFixtures are also automatically cleaned-up between To invoke fixture related methods, obtain StyleFixtures singleton through a factory and invoke a method on it: - jasmine.getStyleFixtures().load(...); + jasmine.getStyleFixtures().load(...) There are also global short cut functions available for the most used methods, so the above example can be rewritten to just: - loadStyleFixtures(...); + loadStyleFixtures(...) Several methods for loading fixtures are provided: @@ -255,10 +255,10 @@ In _myjsonfixture.json_ file: Inside your test: - var data = getJSONFixture('myjsonfixture.json'); + var data = getJSONFixture('myjsonfixture.json') // or load and get the JSON two-step - var fixtures = loadJSONFixtures('myjsonfixture.json'); - var data = fixtures['myjsonfixture.json']; + var fixtures = loadJSONFixtures('myjsonfixture.json') + var data = fixtures['myjsonfixture.json'] expect(myDataManipulator.processData(test_data)).to...) @@ -270,11 +270,11 @@ Because a deep copy of Javascript objects can be a little tricky, this module wi To invoke fixture related methods, obtain Fixtures singleton through a factory and invoke a method on it: - jasmine.getJSONFixtures().load(...); + jasmine.getJSONFixtures().load(...) There are also global short cut functions available for the most used methods, so the above example can be rewritten to just: - loadJSONFixtures(...); + loadJSONFixtures(...) Several methods for loading fixtures are provided: @@ -295,37 +295,37 @@ Spying on jQuery events can be done with `spyOnEvent` and `expect(eventName).toHaveBeenTriggeredOn(selector)` or `expect(spyEvent).toHaveBeenTriggered()` . First, spy on the event: - var spyEvent = spyOnEvent('#some_element', 'click'); - $('#some_element').click(); - expect('click').toHaveBeenTriggeredOn('#some_element'); - expect(spyEvent).toHaveBeenTriggered(); + var spyEvent = spyOnEvent('#some_element', 'click') + $('#some_element').click() + expect('click').toHaveBeenTriggeredOn('#some_element') + expect(spyEvent).toHaveBeenTriggered() You can reset spy events - var spyEvent = spyOnEvent('#some_element', 'click'); - $('#some_element').click(); - expect('click').toHaveBeenTriggeredOn('#some_element'); - expect(spyEvent).toHaveBeenTriggered(); + var spyEvent = spyOnEvent('#some_element', 'click') + $('#some_element').click() + expect('click').toHaveBeenTriggeredOn('#some_element') + expect(spyEvent).toHaveBeenTriggered() // reset spy events - spyEvent.reset(); - expect('click').not.toHaveBeenTriggeredOn('#some_element'); - expect(spyEvent).not.toHaveBeenTriggered(); + spyEvent.reset() + expect('click').not.toHaveBeenTriggeredOn('#some_element') + expect(spyEvent).not.toHaveBeenTriggered() You can similarly check if triggered event was prevented: - var spyEvent = spyOnEvent('#some_element', 'click'); - $('#some_element').click(function(event){event.preventDefault();}); - $('#some_element').click(); - expect('click').toHaveBeenPreventedOn('#some_element'); - expect(spyEvent).toHaveBeenPrevented(); + var spyEvent = spyOnEvent('#some_element', 'click') + $('#some_element').click(function (event){event.preventDefault();}) + $('#some_element').click() + expect('click').toHaveBeenPreventedOn('#some_element') + expect(spyEvent).toHaveBeenPrevented() You can also check if the triggered event was stopped: - var spyEvent = spyOnEvent('#some_element', 'click'); - $('#some_element').click(function(event){event.stopPropagation();}); - $('#some_element').click(); - expect('click').toHaveBeenStoppedOn('#some_element'); - expect(spyEvent).toHaveBeenStopped(); + var spyEvent = spyOnEvent('#some_element', 'click') + $('#some_element').click(function (event){event.stopPropagation();}) + $('#some_element').click() + expect('click').toHaveBeenStoppedOn('#some_element') + expect(spyEvent).toHaveBeenStopped() Much thanks to Luiz Fernando Ribeiro for his [article on Jasmine event spies](http://luizfar.wordpress.com/2011/01/10/testing-events-on-jquery-objects-with-jasmine/). diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 78c1e018..0d796ffd 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -28,63 +28,63 @@ */ +function (jasmine, $, global) { "use strict"; - global.readFixtures = function() { + global.readFixtures = function () { return jasmine.getFixtures().proxyCallTo_('read', arguments) } - global.preloadFixtures = function() { + global.preloadFixtures = function () { jasmine.getFixtures().proxyCallTo_('preload', arguments) } - global.loadFixtures = function() { + global.loadFixtures = function () { jasmine.getFixtures().proxyCallTo_('load', arguments) } - global.appendLoadFixtures = function() { + global.appendLoadFixtures = function () { jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) } - global.setFixtures = function(html) { + global.setFixtures = function (html) { return jasmine.getFixtures().proxyCallTo_('set', arguments) } - global.appendSetFixtures = function() { + global.appendSetFixtures = function () { jasmine.getFixtures().proxyCallTo_('appendSet', arguments) } - global.sandbox = function(attributes) { + global.sandbox = function (attributes) { return jasmine.getFixtures().sandbox(attributes) } - global.spyOnEvent = function(selector, eventName) { + global.spyOnEvent = function (selector, eventName) { return jasmine.JQuery.events.spyOn(selector, eventName) } - global.preloadStyleFixtures = function() { + global.preloadStyleFixtures = function () { jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) } - global.loadStyleFixtures = function() { + global.loadStyleFixtures = function () { jasmine.getStyleFixtures().proxyCallTo_('load', arguments) } - global.appendLoadStyleFixtures = function() { + global.appendLoadStyleFixtures = function () { jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) } - global.setStyleFixtures = function(html) { + global.setStyleFixtures = function (html) { jasmine.getStyleFixtures().proxyCallTo_('set', arguments) } - global.appendSetStyleFixtures = function(html) { + global.appendSetStyleFixtures = function (html) { jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) } - global.loadJSONFixtures = function() { + global.loadJSONFixtures = function () { return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) } - global.getJSONFixture = function(url) { + global.getJSONFixture = function (url) { return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] } @@ -92,43 +92,43 @@ return [$(selector).selector, eventName].toString() } - jasmine.getFixtures = function() { + jasmine.getFixtures = function () { return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures() } - jasmine.getStyleFixtures = function() { + jasmine.getStyleFixtures = function () { return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures() } - jasmine.Fixtures = function() { + jasmine.Fixtures = function () { this.containerId = 'jasmine-fixtures' this.fixturesCache_ = {} this.fixturesPath = 'spec/javascripts/fixtures' } - jasmine.Fixtures.prototype.set = function(html) { + jasmine.Fixtures.prototype.set = function (html) { this.cleanUp() return this.createContainer_(html) } - jasmine.Fixtures.prototype.appendSet= function(html) { + jasmine.Fixtures.prototype.appendSet= function (html) { this.addToContainer_(html) } - jasmine.Fixtures.prototype.preload = function() { + jasmine.Fixtures.prototype.preload = function () { this.read.apply(this, arguments) } - jasmine.Fixtures.prototype.load = function() { + jasmine.Fixtures.prototype.load = function () { this.cleanUp() this.createContainer_(this.read.apply(this, arguments)) } - jasmine.Fixtures.prototype.appendLoad = function() { + jasmine.Fixtures.prototype.appendLoad = function () { this.addToContainer_(this.read.apply(this, arguments)) } - jasmine.Fixtures.prototype.read = function() { + jasmine.Fixtures.prototype.read = function () { var htmlChunks = [] var fixtureUrls = arguments @@ -139,20 +139,20 @@ return htmlChunks.join('') } - jasmine.Fixtures.prototype.clearCache = function() { + jasmine.Fixtures.prototype.clearCache = function () { this.fixturesCache_ = {} } - jasmine.Fixtures.prototype.cleanUp = function() { + jasmine.Fixtures.prototype.cleanUp = function () { $('#' + this.containerId).remove() } - jasmine.Fixtures.prototype.sandbox = function(attributes) { + jasmine.Fixtures.prototype.sandbox = function (attributes) { var attributesToSet = attributes || {} return $('
').attr(attributesToSet) } - jasmine.Fixtures.prototype.createContainer_ = function(html) { + jasmine.Fixtures.prototype.createContainer_ = function (html) { var container = $('
') .attr('id', this.containerId) .html(html) @@ -160,21 +160,21 @@ return container } - jasmine.Fixtures.prototype.addToContainer_ = function(html){ + jasmine.Fixtures.prototype.addToContainer_ = function (html){ var container = $(document.body).find('#'+this.containerId).append(html) if(!container.length){ this.createContainer_(html) } } - jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) { + jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) { if (typeof this.fixturesCache_[url] === 'undefined') { this.loadFixtureIntoCache_(url) } return this.fixturesCache_[url] } - jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) { + jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { var url = this.makeFixtureUrl_(relativeUrl) var request = $.ajax({ type: "GET", @@ -184,50 +184,50 @@ this.fixturesCache_[relativeUrl] = request.responseText } - jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){ + jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){ return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl } - jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) { + jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { return this[methodName].apply(this, passedArguments) } - jasmine.StyleFixtures = function() { + jasmine.StyleFixtures = function () { this.fixturesCache_ = {} this.fixturesNodes_ = [] this.fixturesPath = 'spec/javascripts/fixtures' } - jasmine.StyleFixtures.prototype.set = function(css) { + jasmine.StyleFixtures.prototype.set = function (css) { this.cleanUp() this.createStyle_(css) } - jasmine.StyleFixtures.prototype.appendSet = function(css) { + jasmine.StyleFixtures.prototype.appendSet = function (css) { this.createStyle_(css) } - jasmine.StyleFixtures.prototype.preload = function() { + jasmine.StyleFixtures.prototype.preload = function () { this.read_.apply(this, arguments) } - jasmine.StyleFixtures.prototype.load = function() { + jasmine.StyleFixtures.prototype.load = function () { this.cleanUp() this.createStyle_(this.read_.apply(this, arguments)) } - jasmine.StyleFixtures.prototype.appendLoad = function() { + jasmine.StyleFixtures.prototype.appendLoad = function () { this.createStyle_(this.read_.apply(this, arguments)) } - jasmine.StyleFixtures.prototype.cleanUp = function() { + jasmine.StyleFixtures.prototype.cleanUp = function () { while(this.fixturesNodes_.length) { this.fixturesNodes_.pop().remove() } } - jasmine.StyleFixtures.prototype.createStyle_ = function(html) { + jasmine.StyleFixtures.prototype.createStyle_ = function (html) { var styleText = $('
').html(html).text(), style = $('') @@ -248,21 +248,21 @@ jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ - jasmine.getJSONFixtures = function() { + jasmine.getJSONFixtures = function () { return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures() } - jasmine.JSONFixtures = function() { + jasmine.JSONFixtures = function () { this.fixturesCache_ = {} this.fixturesPath = 'spec/javascripts/fixtures/json' } - jasmine.JSONFixtures.prototype.load = function() { + jasmine.JSONFixtures.prototype.load = function () { this.read.apply(this, arguments) return this.fixturesCache_ } - jasmine.JSONFixtures.prototype.read = function() { + jasmine.JSONFixtures.prototype.read = function () { var fixtureUrls = arguments for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { this.getFixtureData_(fixtureUrls[urlIndex]) @@ -270,16 +270,16 @@ return this.fixturesCache_ } - jasmine.JSONFixtures.prototype.clearCache = function() { + jasmine.JSONFixtures.prototype.clearCache = function () { this.fixturesCache_ = {} } - jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) { + jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) { this.loadFixtureIntoCache_(url) return this.fixturesCache_[url] } - jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) { + jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { var self = this var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl $.ajax({ @@ -287,26 +287,26 @@ cache: false, dataType: 'json', url: url, - success: function(data) { + success: function (data) { self.fixturesCache_[relativeUrl] = data }, - error: function(jqXHR, status, errorThrown) { + error: function (jqXHR, status, errorThrown) { throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') } }) } - jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) { + jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { return this[methodName].apply(this, passedArguments) } - jasmine.JQuery = function() {} + jasmine.JQuery = function () {} - jasmine.JQuery.browserTagCaseIndependentHtml = function(html) { + jasmine.JQuery.browserTagCaseIndependentHtml = function (html) { return $('
').append(html).html() } - jasmine.JQuery.elementToString = function(element) { + jasmine.JQuery.elementToString = function (element) { var domEl = $(element).get(0) if (domEl === undefined || domEl.cloneNode) return $('
').append($(element).clone()).html() @@ -316,15 +316,15 @@ jasmine.JQuery.matchersClass = {} - !function(namespace) { + !function (namespace) { var data = { spiedEvents: {}, handlers: [] } namespace.events = { - spyOn: function(selector, eventName) { - var handler = function(e) { + spyOn: function (selector, eventName) { + var handler = function (e) { data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) } $(selector).on(eventName, handler) @@ -333,13 +333,13 @@ selector: selector, eventName: eventName, handler: handler, - reset: function(){ + reset: function (){ delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] } } }, - args: function(selector, eventName) { + args: function (selector, eventName) { var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] if (!actualArgs) { @@ -349,11 +349,11 @@ return actualArgs }, - wasTriggered: function(selector, eventName) { + wasTriggered: function (selector, eventName) { return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) }, - wasTriggeredWith: function(selector, eventName, expectedArgs, env) { + wasTriggeredWith: function (selector, eventName, expectedArgs, env) { var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1) if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { actualArgs = actualArgs[0] @@ -361,89 +361,89 @@ return env.equals_(expectedArgs, actualArgs) }, - wasPrevented: function(selector, eventName) { + wasPrevented: function (selector, eventName) { var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], e = args ? args[0] : undefined return e && e.isDefaultPrevented() }, - wasStopped: function(selector, eventName) { + wasStopped: function (selector, eventName) { var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], e = args ? args[0] : undefined return e && e.isPropagationStopped() }, - cleanUp: function() { + cleanUp: function () { data.spiedEvents = {} data.handlers = [] } } - }(jasmine.JQuery); + }(jasmine.JQuery) - !function(){ + !function (){ var jQueryMatchers = { - toHaveClass: function(className) { + toHaveClass: function (className) { return this.actual.hasClass(className) }, - toHaveCss: function(css){ + toHaveCss: function (css){ for (var prop in css){ if (this.actual.css(prop) !== css[prop]) return false } return true }, - toBeVisible: function() { + toBeVisible: function () { return this.actual.is(':visible') }, - toBeHidden: function() { + toBeHidden: function () { return this.actual.is(':hidden') }, - toBeSelected: function() { + toBeSelected: function () { return this.actual.is(':selected') }, - toBeChecked: function() { + toBeChecked: function () { return this.actual.is(':checked') }, - toBeEmpty: function() { + toBeEmpty: function () { return this.actual.is(':empty') }, - toExist: function() { + toExist: function () { return $(document).find(this.actual).length }, - toHaveLength: function(length) { + toHaveLength: function (length) { return this.actual.length === length }, - toHaveAttr: function(attributeName, expectedAttributeValue) { + toHaveAttr: function (attributeName, expectedAttributeValue) { return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) }, - toHaveProp: function(propertyName, expectedPropertyValue) { + toHaveProp: function (propertyName, expectedPropertyValue) { return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) }, - toHaveId: function(id) { + toHaveId: function (id) { return this.actual.attr('id') == id }, - toHaveHtml: function(html) { + toHaveHtml: function (html) { return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html) }, - toContainHtml: function(html){ + toContainHtml: function (html){ var actualHtml = this.actual.html() var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) return (actualHtml.indexOf(expectedHtml) >= 0) }, - toHaveText: function(text) { + toHaveText: function (text) { var trimmedText = $.trim(this.actual.text()) if (text && $.isFunction(text.test)) { return text.test(trimmedText) @@ -452,7 +452,7 @@ } }, - toContainText: function(text) { + toContainText: function (text) { var trimmedText = $.trim(this.actual.text()) if (text && $.isFunction(text.test)) { return text.test(trimmedText) @@ -461,35 +461,35 @@ } }, - toHaveValue: function(value) { + toHaveValue: function (value) { return this.actual.val() === value }, - toHaveData: function(key, expectedValue) { + toHaveData: function (key, expectedValue) { return hasProperty(this.actual.data(key), expectedValue) }, - toBe: function(selector) { + toBe: function (selector) { return this.actual.is(selector) }, - toContain: function(selector) { + toContain: function (selector) { return this.actual.find(selector).length }, - toBeMatchedBy: function(selector) { + toBeMatchedBy: function (selector) { return this.actual.filter(selector).length }, - toBeDisabled: function(selector){ + toBeDisabled: function (selector){ return this.actual.is(':disabled') }, - toBeFocused: function(selector) { + toBeFocused: function (selector) { return this.actual[0] === this.actual[0].ownerDocument.activeElement }, - toHandle: function(event) { + toHandle: function (event) { var events = $._data(this.actual.get(0), "events") @@ -515,7 +515,7 @@ }, // tests the existence of a specific event binding + handler - toHandleWith: function(eventName, eventHandler) { + toHandleWith: function (eventName, eventHandler) { var normalizedEventName = eventName.split('.')[0] var stack = $._data(this.actual.get(0), "events")[normalizedEventName] for (var i = 0; i < stack.length; i++) { @@ -525,15 +525,15 @@ } } - var hasProperty = function(actualValue, expectedValue) { + var hasProperty = function (actualValue, expectedValue) { if (expectedValue === undefined) return actualValue !== undefined return actualValue == expectedValue } - var bindMatcher = function(methodName) { + var bindMatcher = function (methodName) { var builtInMatcher = jasmine.Matchers.prototype[methodName] - jasmine.JQuery.matchersClass[methodName] = function() { + jasmine.JQuery.matchersClass[methodName] = function () { if (this.actual && (this.actual instanceof $ || jasmine.isDomNode(this.actual))) { @@ -558,11 +558,11 @@ } }() - beforeEach(function() { + beforeEach(function () { this.addMatchers(jasmine.JQuery.matchersClass) this.addMatchers({ - toHaveBeenTriggeredOn: function(selector) { - this.message = function() { + toHaveBeenTriggeredOn: function (selector) { + this.message = function () { return [ "Expected event " + this.actual + " to have been triggered on " + selector, "Expected event " + this.actual + " not to have been triggered on " + selector @@ -572,10 +572,10 @@ } }) this.addMatchers({ - toHaveBeenTriggered: function(){ + toHaveBeenTriggered: function (){ var eventName = this.actual.eventName, selector = this.actual.selector - this.message = function() { + this.message = function () { return [ "Expected event " + eventName + " to have been triggered on " + selector, "Expected event " + eventName + " not to have been triggered on " + selector @@ -585,11 +585,11 @@ } }) this.addMatchers({ - toHaveBeenTriggeredOnAndWith: function() { + toHaveBeenTriggeredOnAndWith: function () { var selector = arguments[0], expectedArgs = arguments[1], wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) - this.message = function() { + this.message = function () { if (wasTriggered) { var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] return [ @@ -607,8 +607,8 @@ } }) this.addMatchers({ - toHaveBeenPreventedOn: function(selector) { - this.message = function() { + toHaveBeenPreventedOn: function (selector) { + this.message = function () { return [ "Expected event " + this.actual + " to have been prevented on " + selector, "Expected event " + this.actual + " not to have been prevented on " + selector @@ -618,10 +618,10 @@ } }) this.addMatchers({ - toHaveBeenPrevented: function() { + toHaveBeenPrevented: function () { var eventName = this.actual.eventName, selector = this.actual.selector - this.message = function() { + this.message = function () { return [ "Expected event " + eventName + " to have been prevented on " + selector, "Expected event " + eventName + " not to have been prevented on " + selector @@ -631,8 +631,8 @@ } }) this.addMatchers({ - toHaveBeenStoppedOn: function(selector) { - this.message = function() { + toHaveBeenStoppedOn: function (selector) { + this.message = function () { return [ "Expected event " + this.actual + " to have been stopped on " + selector, "Expected event " + this.actual + " not to have been stopped on " + selector @@ -642,10 +642,10 @@ } }) this.addMatchers({ - toHaveBeenStopped: function() { + toHaveBeenStopped: function () { var eventName = this.actual.eventName, selector = this.actual.selector - this.message = function() { + this.message = function () { return [ "Expected event " + eventName + " to have been stopped on " + selector, "Expected event " + eventName + " not to have been stopped on " + selector @@ -654,7 +654,7 @@ return jasmine.JQuery.events.wasStopped(selector, eventName) } }) - jasmine.getEnv().addEqualityTester(function(a, b) { + jasmine.getEnv().addEqualityTester(function (a, b) { if(a instanceof jQuery && b instanceof jQuery) { if(a.size() != b.size()) { return jasmine.undefined @@ -668,7 +668,7 @@ }) }) - afterEach(function() { + afterEach(function () { jasmine.getFixtures().cleanUp() jasmine.getStyleFixtures().cleanUp() jasmine.JQuery.events.cleanUp() diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 455c1f25..e490fe5e 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -1,34 +1,34 @@ -describe("jasmine.Fixtures", function() { +describe("jasmine.Fixtures", function () { var ajaxData = 'some ajax data' var fixtureUrl = 'some_url' var anotherFixtureUrl = 'another_url' - var fixturesContainer = function() { + var fixturesContainer = function () { return $('#' + jasmine.getFixtures().containerId) } - var appendFixturesContainerToDom = function() { + var appendFixturesContainerToDom = function () { $('body').append('
old content
') } - beforeEach(function() { + beforeEach(function () { jasmine.getFixtures().clearCache() - spyOn(jasmine.Fixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function(relativeUrl){ + spyOn(jasmine.Fixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function (relativeUrl){ this.fixturesCache_[relativeUrl] = ajaxData }) }) - describe("default initial config values", function() { - it("should set 'jasmine-fixtures' as the default container id", function() { + describe("default initial config values", function () { + it("should set 'jasmine-fixtures' as the default container id", function () { expect(jasmine.getFixtures().containerId).toEqual('jasmine-fixtures') }) - it("should set 'spec/javascripts/fixtures' as the default fixtures path", function() { + it("should set 'spec/javascripts/fixtures' as the default fixtures path", function () { expect(jasmine.getFixtures().fixturesPath).toEqual('spec/javascripts/fixtures') }) }) - describe("cache", function() { - describe("clearCache", function() { - it("should clear cache and in effect force subsequent AJAX call", function() { + describe("cache", function () { + describe("clearCache", function () { + it("should clear cache and in effect force subsequent AJAX call", function () { jasmine.getFixtures().read(fixtureUrl) jasmine.getFixtures().clearCache() jasmine.getFixtures().read(fixtureUrl) @@ -36,94 +36,94 @@ describe("jasmine.Fixtures", function() { }) }) - it("first-time read should go through AJAX", function() { + it("first-time read should go through AJAX", function () { jasmine.getFixtures().read(fixtureUrl) expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1) }) - it("subsequent read from the same URL should go from cache", function() { + it("subsequent read from the same URL should go from cache", function () { jasmine.getFixtures().read(fixtureUrl, fixtureUrl) expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1) - }); + }) }) - describe("read", function() { - it("should return fixture HTML", function() { + describe("read", function () { + it("should return fixture HTML", function () { var html = jasmine.getFixtures().read(fixtureUrl) expect(html).toEqual(ajaxData) }) - it("should return duplicated HTML of a fixture when its url is provided twice in a single call", function() { + it("should return duplicated HTML of a fixture when its url is provided twice in a single call", function () { var html = jasmine.getFixtures().read(fixtureUrl, fixtureUrl) expect(html).toEqual(ajaxData + ajaxData) }) - it("should return merged HTML of two fixtures when two different urls are provided in a single call", function() { + it("should return merged HTML of two fixtures when two different urls are provided in a single call", function () { var html = jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl) expect(html).toEqual(ajaxData + ajaxData) }) - it("should have shortcut global method readFixtures", function() { + it("should have shortcut global method readFixtures", function () { var html = readFixtures(fixtureUrl, anotherFixtureUrl) expect(html).toEqual(ajaxData + ajaxData) }) - it("should use the configured fixtures path concatenating it to the requested url (without concatenating a slash if it already has an ending one)", function() { + it("should use the configured fixtures path concatenating it to the requested url (without concatenating a slash if it already has an ending one)", function () { jasmine.getFixtures().fixturesPath = 'a path ending with slash/' expect(jasmine.getFixtures().makeFixtureUrl_(fixtureUrl)).toEqual('a path ending with slash/'+fixtureUrl) }) - it("should use the configured fixtures path concatenating it to the requested url (concatenating a slash if it doesn't have an ending one)", function() { + it("should use the configured fixtures path concatenating it to the requested url (concatenating a slash if it doesn't have an ending one)", function () { jasmine.getFixtures().fixturesPath = 'a path without an ending slash' expect(jasmine.getFixtures().makeFixtureUrl_(fixtureUrl)).toEqual('a path without an ending slash/'+fixtureUrl) }) }) - describe("load", function() { - it("should insert fixture HTML into container", function() { + describe("load", function () { + it("should insert fixture HTML into container", function () { jasmine.getFixtures().load(fixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData) }) - it("should insert duplicated fixture HTML into container when the same url is provided twice in a single call", function() { + it("should insert duplicated fixture HTML into container when the same url is provided twice in a single call", function () { jasmine.getFixtures().load(fixtureUrl, fixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - it("should insert merged HTML of two fixtures into container when two different urls are provided in a single call", function() { + it("should insert merged HTML of two fixtures into container when two different urls are provided in a single call", function () { jasmine.getFixtures().load(fixtureUrl, anotherFixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - it("should have shortcut global method loadFixtures", function() { + it("should have shortcut global method loadFixtures", function () { loadFixtures(fixtureUrl, anotherFixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - describe("when fixture container does not exist", function() { - it("should automatically create fixtures container and append it to DOM", function() { + describe("when fixture container does not exist", function () { + it("should automatically create fixtures container and append it to DOM", function () { jasmine.getFixtures().load(fixtureUrl) expect(fixturesContainer().size()).toEqual(1) - }); + }) }) - describe("when fixture container exists", function() { - beforeEach(function() { + describe("when fixture container exists", function () { + beforeEach(function () { appendFixturesContainerToDom() }) - it("should replace it with new content", function() { + it("should replace it with new content", function () { jasmine.getFixtures().load(fixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData) }) }) - describe("when fixture contains an inline
" + describe("when fixture contains an inline
" }) - it("should execute the inline javascript after the fixture has been inserted into the body", function(){ + it("should execute the inline javascript after the fixture has been inserted into the body", function (){ jasmine.getFixtures().load(fixtureUrl) expect($("#anchor_01")).toHaveClass('foo') }) @@ -131,128 +131,128 @@ describe("jasmine.Fixtures", function() { }) - describe("appendLoad", function() { - beforeEach(function(){ + describe("appendLoad", function () { + beforeEach(function (){ ajaxData = 'some ajax data' }) - it("should insert fixture HTML into container", function() { + it("should insert fixture HTML into container", function () { jasmine.getFixtures().appendLoad(fixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData) }) - it("should insert duplicated fixture HTML into container when the same url is provided twice in a single call", function() { + it("should insert duplicated fixture HTML into container when the same url is provided twice in a single call", function () { jasmine.getFixtures().appendLoad(fixtureUrl, fixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - it("should insert merged HTML of two fixtures into container when two different urls are provided in a single call", function() { + it("should insert merged HTML of two fixtures into container when two different urls are provided in a single call", function () { jasmine.getFixtures().appendLoad(fixtureUrl, anotherFixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - it("should have shortcut global method loadFixtures", function() { + it("should have shortcut global method loadFixtures", function () { appendLoadFixtures(fixtureUrl, anotherFixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - it("should automatically create fixtures container and append it to DOM", function() { + it("should automatically create fixtures container and append it to DOM", function () { jasmine.getFixtures().appendLoad(fixtureUrl) expect(fixturesContainer().size()).toEqual(1) }) - describe("with a prexisting fixture",function(){ - beforeEach(function() { + describe("with a prexisting fixture",function (){ + beforeEach(function () { jasmine.getFixtures().appendLoad(fixtureUrl) }) - it("should add new content", function() { + it("should add new content", function () { jasmine.getFixtures().appendLoad(fixtureUrl) expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData) }) - it("should not add a new fixture container", function(){ + it("should not add a new fixture container", function (){ jasmine.getFixtures().appendLoad(fixtureUrl) expect(fixturesContainer().size()).toEqual(1) }) }) - describe("when fixture contains an inline
" + describe("when fixture contains an inline
" }) - it("should execute the inline javascript after the fixture has been inserted into the body", function(){ + it("should execute the inline javascript after the fixture has been inserted into the body", function (){ jasmine.getFixtures().appendLoad(fixtureUrl) expect($("#anchor_01")).toHaveClass('foo') }) }) }) - describe("preload", function() { - describe("read after preload", function() { - it("should go from cache", function() { + describe("preload", function () { + describe("read after preload", function () { + it("should go from cache", function () { jasmine.getFixtures().preload(fixtureUrl, anotherFixtureUrl) jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl) expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2) }) - it("should return correct HTMLs", function() { + it("should return correct HTMLs", function () { jasmine.getFixtures().preload(fixtureUrl, anotherFixtureUrl) var html = jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl) expect(html).toEqual(ajaxData + ajaxData) }) }) - it("should not preload the same fixture twice", function() { + it("should not preload the same fixture twice", function () { jasmine.getFixtures().preload(fixtureUrl, fixtureUrl) expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1) }) - it("should have shortcut global method preloadFixtures", function() { + it("should have shortcut global method preloadFixtures", function () { preloadFixtures(fixtureUrl, anotherFixtureUrl) jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl) expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2) }) }) - describe("set", function() { + describe("set", function () { var html = '
some HTML
' - it("should insert HTML into container", function() { + it("should insert HTML into container", function () { jasmine.getFixtures().set(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - it("should insert jQuery element into container", function() { + it("should insert jQuery element into container", function () { jasmine.getFixtures().set($(html)) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - describe("when fixture container does not exist", function() { - it("should automatically create fixtures container and append it to DOM", function() { + describe("when fixture container does not exist", function () { + it("should automatically create fixtures container and append it to DOM", function () { jasmine.getFixtures().set(html) expect(fixturesContainer().size()).toEqual(1) }) - it("should return the fixture container", function() { + it("should return the fixture container", function () { var container = jasmine.getFixtures().set(html) expect(container).toExist() expect(container[0]).toEqual(fixturesContainer()[0]) }) }) - describe("when fixture container exists", function() { - beforeEach(function() { + describe("when fixture container exists", function () { + beforeEach(function () { appendFixturesContainerToDom() }) - it("should replace it with new content", function() { + it("should replace it with new content", function () { jasmine.getFixtures().set(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - it("should return the fixture container", function(){ + it("should return the fixture container", function (){ var container = jasmine.getFixtures().set(html) expect(container).toExist() expect(container[0]).toEqual(fixturesContainer()[0]) @@ -260,66 +260,66 @@ describe("jasmine.Fixtures", function() { }) }) - describe("setFixtures", function() { + describe("setFixtures", function () { var html = '
some HTML
' - it("should be a shortcut global method", function() { + it("should be a shortcut global method", function () { setFixtures(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - it("should return the fixture container", function() { + it("should return the fixture container", function () { var container = setFixtures(html) expect(container).toExist() expect(container[0]).toEqual(fixturesContainer()[0]) }) - }); + }) - describe("appendSet",function(){ + describe("appendSet",function (){ var html = '
some HTML
' - it("should insert HTML into container", function() { + it("should insert HTML into container", function () { jasmine.getFixtures().appendSet(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - it("should insert jQuery element into container", function() { + it("should insert jQuery element into container", function () { jasmine.getFixtures().appendSet($(html)) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - it("should have shortcut global method setFixtures", function() { + it("should have shortcut global method setFixtures", function () { appendSetFixtures(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) - describe("when fixture container does not exist", function() { - it("should automatically create fixtures container and append it to DOM", function() { + describe("when fixture container does not exist", function () { + it("should automatically create fixtures container and append it to DOM", function () { jasmine.getFixtures().appendSet(html) expect(fixturesContainer().size()).toEqual(1) }) }) - describe("when fixture container exists", function() { - beforeEach(function() { + describe("when fixture container exists", function () { + beforeEach(function () { jasmine.getFixtures().appendSet(html) }) - it("should add new content", function() { + it("should add new content", function () { jasmine.getFixtures().appendSet(html) expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)+jasmine.JQuery.browserTagCaseIndependentHtml(html)) }) }) }) - describe("sandbox", function() { - describe("with no attributes parameter specified", function() { - it("should create DIV with id #sandbox", function() { + describe("sandbox", function () { + describe("with no attributes parameter specified", function () { + it("should create DIV with id #sandbox", function () { expect(jasmine.getFixtures().sandbox().html()).toEqual($('
').html()) }) }) - describe("with attributes parameter specified", function() { - it("should create DIV with attributes", function() { + describe("with attributes parameter specified", function () { + it("should create DIV with attributes", function () { var attributes = { attr1: 'attr1 value', attr2: 'attr2 value' @@ -330,14 +330,14 @@ describe("jasmine.Fixtures", function() { expect(element.attr('attr2')).toEqual(attributes.attr2) }) - it("should be able to override id by setting it as attribute", function() { + it("should be able to override id by setting it as attribute", function () { var idOverride = 'overridden' var element = $(jasmine.getFixtures().sandbox({id: idOverride})) expect(element.attr('id')).toEqual(idOverride) }) }) - it("should have shortcut global method sandbox", function() { + it("should have shortcut global method sandbox", function () { var attributes = { id: 'overridden' } @@ -346,8 +346,8 @@ describe("jasmine.Fixtures", function() { }) }) - describe("cleanUp", function() { - it("should remove fixtures container from DOM", function() { + describe("cleanUp", function () { + it("should remove fixtures container from DOM", function () { appendFixturesContainerToDom() jasmine.getFixtures().cleanUp() expect(fixturesContainer().size()).toEqual(0) @@ -356,46 +356,46 @@ describe("jasmine.Fixtures", function() { // WARNING: this block requires its two tests to be invoked in order! // (Really ugly solution, but unavoidable in this specific case) - describe("automatic DOM clean-up between tests", function() { + describe("automatic DOM clean-up between tests", function () { // WARNING: this test must be invoked first (before 'SECOND TEST')! - it("FIRST TEST: should pollute the DOM", function() { + it("FIRST TEST: should pollute the DOM", function () { appendFixturesContainerToDom() }) // WARNING: this test must be invoked second (after 'FIRST TEST')! - it("SECOND TEST: should see the DOM in a blank state", function() { + it("SECOND TEST: should see the DOM in a blank state", function () { expect(fixturesContainer().size()).toEqual(0) }) }) }) -describe("jasmine.Fixtures using real AJAX call", function() { +describe("jasmine.Fixtures using real AJAX call", function () { var defaultFixturesPath - beforeEach(function() { + beforeEach(function () { defaultFixturesPath = jasmine.getFixtures().fixturesPath jasmine.getFixtures().fixturesPath = 'spec/fixtures' }) - afterEach(function() { + afterEach(function () { jasmine.getFixtures().fixturesPath = defaultFixturesPath }) - describe("when fixture file exists", function() { + describe("when fixture file exists", function () { var fixtureUrl = "real_non_mocked_fixture.html" - it("should load content of fixture file", function() { + it("should load content of fixture file", function () { var fixtureContent = jasmine.getFixtures().read(fixtureUrl) expect(fixtureContent).toEqual('
') }) }) /* TODO : start throwing again - describe("when fixture file does not exist", function() { + describe("when fixture file does not exist", function () { var fixtureUrl = "not_existing_fixture" - it("should throw an exception", function() { - expect(function() { + it("should throw an exception", function () { + expect(function () { jasmine.getFixtures().read(fixtureUrl) }).toThrow() }) @@ -404,59 +404,59 @@ describe("jasmine.Fixtures using real AJAX call", function() { }) -describe("jQuery matchers", function() { - describe("when jQuery matcher hides original Jasmine matcher", function() { - describe("and tested item is jQuery object", function() { - it("should invoke jQuery version of matcher", function() { +describe("jQuery matchers", function () { + describe("when jQuery matcher hides original Jasmine matcher", function () { + describe("and tested item is jQuery object", function () { + it("should invoke jQuery version of matcher", function () { expect($('
')).toBe('div') }) }) - describe("and tested item is not jQuery object", function() { - it("should invoke original version of matcher", function() { + describe("and tested item is not jQuery object", function () { + it("should invoke original version of matcher", function () { expect(true).toBe(true) }) }) - describe("and tested item is a dom object", function() { - it("should invoke jquery version of matcher", function() { + describe("and tested item is a dom object", function () { + it("should invoke jquery version of matcher", function () { expect($('
').get(0)).toBe('div') }) }) }) - describe("when jQuery matcher does not hide any original Jasmine matcher", function() { - describe("and tested item in not jQuery object", function() { - it("should pass negated", function() { + describe("when jQuery matcher does not hide any original Jasmine matcher", function () { + describe("and tested item in not jQuery object", function () { + it("should pass negated", function () { expect({}).not.toHaveClass("some-class") }) }) }) - describe("when invoked multiple times on the same fixture", function() { - it("should not reset fixture after first call", function() { + describe("when invoked multiple times on the same fixture", function () { + it("should not reset fixture after first call", function () { setFixtures(sandbox()) expect($('#sandbox')).toExist() expect($('#sandbox')).toExist() }) }) - describe("toHaveClass", function() { + describe("toHaveClass", function () { var className = "some-class" - it("should pass when class found", function() { + it("should pass when class found", function () { setFixtures(sandbox({'class': className})) expect($('#sandbox')).toHaveClass(className) expect($('#sandbox').get(0)).toHaveClass(className) }) - it("should pass negated when class not found", function() { + it("should pass negated when class not found", function () { setFixtures(sandbox()) expect($('#sandbox')).not.toHaveClass(className) expect($('#sandbox').get(0)).not.toHaveClass(className) }) - it("should not crash when documentElement provided", function(){ + it("should not crash when documentElement provided", function (){ var doc = $(document.documentElement).addClass(className) expect(doc).toHaveClass(className) doc.removeClass(className) @@ -464,332 +464,332 @@ describe("jQuery matchers", function() { }) }) - describe("toHaveAttr", function() { + describe("toHaveAttr", function () { var attributeName = 'attr1' var attributeValue = 'attr1 value' var wrongAttributeName = 'wrongName' var wrongAttributeValue = 'wrong value' - beforeEach(function() { + beforeEach(function () { var attributes = {} attributes[attributeName] = attributeValue setFixtures(sandbox(attributes)) }) - describe("when only attribute name is provided", function() { - it("should pass if element has matching attribute", function() { + describe("when only attribute name is provided", function () { + it("should pass if element has matching attribute", function () { expect($('#sandbox')).toHaveAttr(attributeName) expect($('#sandbox').get(0)).toHaveAttr(attributeName) }) - it("should pass negated if element has no matching attribute", function() { + it("should pass negated if element has no matching attribute", function () { expect($('#sandbox')).not.toHaveAttr(wrongAttributeName) expect($('#sandbox').get(0)).not.toHaveAttr(wrongAttributeName) }) }) - describe("when both attribute name and value are provided", function() { - it("should pass if element has matching attribute with matching value", function() { + describe("when both attribute name and value are provided", function () { + it("should pass if element has matching attribute with matching value", function () { expect($('#sandbox')).toHaveAttr(attributeName, attributeValue) expect($('#sandbox').get(0)).toHaveAttr(attributeName, attributeValue) }) - it("should pass negated if element has matching attribute but with wrong value", function() { + it("should pass negated if element has matching attribute but with wrong value", function () { expect($('#sandbox')).not.toHaveAttr(attributeName, wrongAttributeValue) expect($('#sandbox').get(0)).not.toHaveAttr(attributeName, wrongAttributeValue) }) - it("should pass negated if element has no matching attribute", function() { + it("should pass negated if element has no matching attribute", function () { expect($('#sandbox')).not.toHaveAttr(wrongAttributeName, attributeValue) expect($('#sandbox').get(0)).not.toHaveAttr(wrongAttributeName, attributeValue) }) }) }) - describe("toHaveProp", function() { + describe("toHaveProp", function () { var propertyName = 'prop1' var propertyValue = 'prop1 value' var wrongPropertyName = 'wrongName' var wrongPropertyValue = 'wrong value' - beforeEach(function() { + beforeEach(function () { setFixtures(sandbox()) var element = $('#sandbox')[0] element[propertyName] = propertyValue }) - describe("when only property name is provided", function() { - it("should pass if element has matching property", function() { + describe("when only property name is provided", function () { + it("should pass if element has matching property", function () { expect($('#sandbox')).toHaveProp(propertyName) }) - it("should pass negated if element has no matching property", function() { + it("should pass negated if element has no matching property", function () { expect($('#sandbox')).not.toHaveProp(wrongPropertyName) }) }) - describe("when both property name and value are provided", function() { - it("should pass if element has matching property with matching value", function() { + describe("when both property name and value are provided", function () { + it("should pass if element has matching property with matching value", function () { expect($('#sandbox')).toHaveProp(propertyName, propertyValue) }) - it("should pass negated if element has matching property but with wrong value", function() { + it("should pass negated if element has matching property but with wrong value", function () { expect($('#sandbox')).not.toHaveProp(propertyName, wrongPropertyValue) }) - it("should pass negated if element has no matching property", function() { + it("should pass negated if element has no matching property", function () { expect($('#sandbox')).not.toHaveProp(wrongPropertyName, propertyValue) }) }) }) - describe("toHaveCss", function(){ - beforeEach(function(){ + describe("toHaveCss", function (){ + beforeEach(function (){ setFixtures(sandbox()) }) - it("should pass if the element has matching css", function(){ + it("should pass if the element has matching css", function (){ $("#sandbox").css("display", "none") $("#sandbox").css("margin-left", "10px") expect($("#sandbox")).toHaveCss({display: "none", "margin-left": "10px"}) }) - it("should be able to check a subset of element's css", function(){ + it("should be able to check a subset of element's css", function (){ $("#sandbox").css("display", "none") $("#sandbox").css("margin-left", "10px") expect($("#sandbox")).toHaveCss({"margin-left": "10px"}) }) - it("should fail if the element doesn't have matching css", function(){ + it("should fail if the element doesn't have matching css", function (){ $("#sandbox").css("display", "none") $("#sandbox").css("margin-left", "20px") expect($("#sandbox")).not.toHaveCss({display: "none", "margin-left": "10px"}) }) }) - describe("toHaveId", function() { - beforeEach(function() { + describe("toHaveId", function () { + beforeEach(function () { setFixtures(sandbox()) }) - it("should pass if id attribute matches expectation", function() { + it("should pass if id attribute matches expectation", function () { expect($('#sandbox')).toHaveId('sandbox') expect($('#sandbox').get(0)).toHaveId('sandbox') }) - it("should pass negated if id attribute does not match expectation", function() { + it("should pass negated if id attribute does not match expectation", function () { expect($('#sandbox')).not.toHaveId('wrongId') expect($('#sandbox').get(0)).not.toHaveId('wrongId') }) - it("should pass negated if id attribute is not present", function() { + it("should pass negated if id attribute is not present", function () { expect($('
')).not.toHaveId('sandbox') expect($('
').get(0)).not.toHaveId('sandbox') }) }) - describe("toHaveHtml", function() { + describe("toHaveHtml", function () { var html = '
some text
' var wrongHtml = 'some text' var element - beforeEach(function() { + beforeEach(function () { element = $('
').append(html) }) - it("should pass when html matches", function() { + it("should pass when html matches", function () { expect(element).toHaveHtml(html) expect(element.get(0)).toHaveHtml(html) }) - it("should pass negated when html does not match", function() { + it("should pass negated when html does not match", function () { expect(element).not.toHaveHtml(wrongHtml) expect(element.get(0)).not.toHaveHtml(wrongHtml) }) }) - describe("toContainHtml", function(){ - beforeEach(function(){ + describe("toContainHtml", function (){ + beforeEach(function (){ setFixtures(sandbox()) }) - it("should pass when the element contains given html", function(){ + it("should pass when the element contains given html", function (){ $("#sandbox").html("

    foo

    ") expect($("#sandbox")).toContainHtml("
      ") }) - it("should fail when the element doesn't contain given html", function(){ + it("should fail when the element doesn't contain given html", function (){ $("#sandbox").html("

      foo

      ") expect($("#sandbox")).not.toContainHtml("
        ") }) }) - describe("toHaveText", function() { + describe("toHaveText", function () { var text = 'some text' var wrongText = 'some other text' var element - beforeEach(function() { + beforeEach(function () { element = $('
        ').append(text) }) - it("should pass when text matches", function() { + it("should pass when text matches", function () { expect(element).toHaveText(text) expect(element.get(0)).toHaveText(text) }) - it("should ignore surrounding whitespace", function() { + it("should ignore surrounding whitespace", function () { element = $('
        \n' + text + '\n
        ') expect(element).toHaveText(text) expect(element.get(0)).toHaveText(text) }) - it("should pass negated when text does not match", function() { + it("should pass negated when text does not match", function () { expect(element).not.toHaveText(wrongText) expect(element.get(0)).not.toHaveText(wrongText) }) - it('should pass when text matches a regex', function() { + it('should pass when text matches a regex', function () { expect(element).toHaveText(/some/) expect(element.get(0)).toHaveText(/some/) }) - it('should pass negated when text does not match a regex', function() { + it('should pass negated when text does not match a regex', function () { expect(element).not.toHaveText(/other/) expect(element.get(0)).not.toHaveText(/other/) }) }) - describe("toContainText", function() { + describe("toContainText", function () { var text = 'some pretty long bits of text' - var textPart = 'pret'; + var textPart = 'pret' var wrongText = 'some other text' var element - beforeEach(function() { + beforeEach(function () { element = $('
        ').append(text) }) - it("should pass when text contains text part", function() { + it("should pass when text contains text part", function () { expect(element).toContainText(textPart) expect(element.get(0)).toContainText(textPart) }) - it("should pass negated when text does not match", function() { + it("should pass negated when text does not match", function () { expect(element).not.toContainText(wrongText) expect(element.get(0)).not.toContainText(wrongText) }) - it('should pass when text matches a regex', function() { + it('should pass when text matches a regex', function () { expect(element).toContainText(/some/) expect(element.get(0)).toContainText(/some/) }) - it('should pass negated when text does not match a regex', function() { + it('should pass negated when text does not match a regex', function () { expect(element).not.toContainText(/other/) expect(element.get(0)).not.toContainText(/other/) }) }) - describe("toHaveValue", function() { + describe("toHaveValue", function () { var value = 'some value' var differentValue = 'different value' - beforeEach(function() { + beforeEach(function () { setFixtures($('').val(value)) }) - it("should pass if value matches expectation", function() { + it("should pass if value matches expectation", function () { expect($('#sandbox')).toHaveValue(value) expect($('#sandbox').get(0)).toHaveValue(value) }) - it("should pass negated if value does not match expectation", function() { + it("should pass negated if value does not match expectation", function () { expect($('#sandbox')).not.toHaveValue(differentValue) expect($('#sandbox').get(0)).not.toHaveValue(differentValue) }) - it("should pass negated if value attribute is not present", function() { + it("should pass negated if value attribute is not present", function () { expect(sandbox()).not.toHaveValue(value) expect(sandbox().get(0)).not.toHaveValue(value) }) - it("should not coerce types", function(){ + it("should not coerce types", function (){ setFixtures($('').val("")) expect($('#sandbox')).not.toHaveValue(0) }) }) - describe("toHaveData", function() { + describe("toHaveData", function () { var key = 'some key' var value = 'some value' var wrongKey = 'wrong key' var wrongValue = 'wrong value' - beforeEach(function() { + beforeEach(function () { setFixtures(sandbox().data(key, value)) }) - describe("when only key is provided", function() { - it("should pass if element has matching data key", function() { + describe("when only key is provided", function () { + it("should pass if element has matching data key", function () { expect($('#sandbox')).toHaveData(key) expect($('#sandbox').get(0)).toHaveData(key) }) - it("should pass negated if element has no matching data key", function() { + it("should pass negated if element has no matching data key", function () { expect($('#sandbox')).not.toHaveData(wrongKey) expect($('#sandbox').get(0)).not.toHaveData(wrongKey) }) }) - describe("when both key and value are provided", function() { - it("should pass if element has matching key with matching value", function() { + describe("when both key and value are provided", function () { + it("should pass if element has matching key with matching value", function () { expect($('#sandbox')).toHaveData(key, value) expect($('#sandbox').get(0)).toHaveData(key, value) }) - it("should pass negated if element has matching key but with wrong value", function() { + it("should pass negated if element has matching key but with wrong value", function () { expect($('#sandbox')).not.toHaveData(key, wrongValue) expect($('#sandbox').get(0)).not.toHaveData(key, wrongValue) }) - it("should pass negated if element has no matching key", function() { + it("should pass negated if element has no matching key", function () { expect($('#sandbox')).not.toHaveData(wrongKey, value) expect($('#sandbox').get(0)).not.toHaveData(wrongKey, value) }) }) }) - describe("toBeVisible", function() { - it("should pass on visible element", function() { + describe("toBeVisible", function () { + it("should pass on visible element", function () { setFixtures(sandbox()) expect($('#sandbox')).toBeVisible() expect($('#sandbox').get(0)).toBeVisible() }) - it("should pass negated on hidden element", function() { + it("should pass negated on hidden element", function () { setFixtures(sandbox().hide()) expect($('#sandbox')).not.toBeVisible() expect($('#sandbox').get(0)).not.toBeVisible() }) }) - describe("toBeHidden", function() { - it("should pass on hidden element", function() { + describe("toBeHidden", function () { + it("should pass on hidden element", function () { setFixtures(sandbox().hide()) expect($('#sandbox')).toBeHidden() expect($('#sandbox').get(0)).toBeHidden() }) - it("should pass negated on visible element", function() { + it("should pass negated on visible element", function () { setFixtures(sandbox()) expect($('#sandbox')).not.toBeHidden() expect($('#sandbox').get(0)).not.toBeHidden() }) }) - describe("toBeSelected", function() { - beforeEach(function() { + describe("toBeSelected", function () { + beforeEach(function () { setFixtures('\ ') }) - it("should pass on selected element", function() { + it("should pass on selected element", function () { expect($('#selected')).toBeSelected() expect($('#selected').get(0)).toBeSelected() }) - it("should pass negated on not selected element", function() { + it("should pass negated on not selected element", function () { expect($('#not-selected')).not.toBeSelected() expect($('#not-selected').get(0)).not.toBeSelected() }) }) - describe("toBeChecked", function() { - beforeEach(function() { + describe("toBeChecked", function () { + beforeEach(function () { setFixtures('\ \n\ ') }) - it("should pass on checked element", function() { + it("should pass on checked element", function () { expect($('#checked')).toBeChecked() expect($('#checked').get(0)).toBeChecked() }) - it("should pass negated on not checked element", function() { + it("should pass negated on not checked element", function () { expect($('#not-checked')).not.toBeChecked() expect($('#not-checked').get(0)).not.toBeChecked() }) }) - describe("toBeEmpty", function() { - it("should pass on empty element", function() { + describe("toBeEmpty", function () { + it("should pass on empty element", function () { setFixtures(sandbox()) expect($('#sandbox')).toBeEmpty() expect($('#sandbox').get(0)).toBeEmpty() }) - it("should pass negated on element with a tag inside", function() { + it("should pass negated on element with a tag inside", function () { setFixtures(sandbox().html($(''))) expect($('#sandbox')).not.toBeEmpty() expect($('#sandbox').get(0)).not.toBeEmpty() }) - it("should pass negated on element with text inside", function() { + it("should pass negated on element with text inside", function () { setFixtures(sandbox().text('some text')) expect($('#sandbox')).not.toBeEmpty() expect($('#sandbox').get(0)).not.toBeEmpty() }) }) - describe("toExist", function() { - it("should pass on visible element", function() { + describe("toExist", function () { + it("should pass on visible element", function () { setFixtures(sandbox()) expect($('#sandbox')).toExist() expect($('#sandbox').get(0)).toExist() }) - it("should pass on hidden element", function() { + it("should pass on hidden element", function () { setFixtures(sandbox().hide()) expect($('#sandbox')).toExist() expect($('#sandbox').get(0)).toExist() }) - it("should pass negated if element is not present in DOM", function() { + it("should pass negated if element is not present in DOM", function () { expect($('#non-existent-element')).not.toExist() expect($('#non-existent-element').get(0)).not.toExist() }) - it("should pass on negated removed element", function(){ + it("should pass on negated removed element", function (){ setFixtures(sandbox()) var el = $("#sandbox") el.remove() @@ -872,170 +872,170 @@ describe("jQuery matchers", function() { }) }) - describe("toHaveLength", function() { - it("should pass on an object with more than zero items", function() { + describe("toHaveLength", function () { + it("should pass on an object with more than zero items", function () { var $three = $('
        ').add('').add("
        ")
               expect($three.length).toBe(3)
               expect($three).toHaveLength(3)
             })
        -    it("should pass negated on an object with more than zero items", function() {
        +    it("should pass negated on an object with more than zero items", function () {
               var $three = $('
        ').add('').add("
        ")
               expect($three.length).toBe(3)
               expect($three).not.toHaveLength(2)
             })
         
        -    it("should pass on an object with zero items", function() {
        +    it("should pass on an object with zero items", function () {
               var $zero = $()
               expect($zero.length).toBe(0)
               expect($zero).toHaveLength(0)
             })
         
        -    it("should pass negated on an object with zero items", function() {
        +    it("should pass negated on an object with zero items", function () {
               var $zero = $()
               expect($zero.length).not.toBe(1)
               expect($zero).not.toHaveLength(1)
             })
           })
         
        -  describe("toBe", function() {
        -    beforeEach(function() {
        +  describe("toBe", function () {
        +    beforeEach(function () {
               setFixtures(sandbox())
             })
         
        -    it("should pass if object matches selector", function() {
        +    it("should pass if object matches selector", function () {
               expect($('#sandbox')).toBe('#sandbox')
               expect($('#sandbox').get(0)).toBe('#sandbox')
             })
         
        -    it("should pass negated if object does not match selector", function() {
        +    it("should pass negated if object does not match selector", function () {
               expect($('#sandbox')).not.toBe('#wrong-id')
               expect($('#sandbox').get(0)).not.toBe('#wrong-id')
             })
           })
         
        -  describe("toContain", function() {
        -    beforeEach(function() {
        +  describe("toContain", function () {
        +    beforeEach(function () {
               setFixtures(sandbox().html(''))
             })
         
        -    it("should pass if object contains selector", function() {
        +    it("should pass if object contains selector", function () {
               expect($('#sandbox')).toContain('span')
               expect($('#sandbox').get(0)).toContain('span')
             })
         
        -    it("should pass negated if object does not contain selector", function() {
        +    it("should pass negated if object does not contain selector", function () {
               expect($('#sandbox')).not.toContain('div')
               expect($('#sandbox').get(0)).not.toContain('div')
             })
           })
         
        -  describe("toBeMatchedBy", function() {
        -    beforeEach(function() {
        +  describe("toBeMatchedBy", function () {
        +    beforeEach(function () {
               setFixtures(sandbox().html(''))
             })
         
        -    it("should pass if selector contains given selector", function() {
        -      expect($('#sandbox span')).toBeMatchedBy('#js-match');
        +    it("should pass if selector contains given selector", function () {
        +      expect($('#sandbox span')).toBeMatchedBy('#js-match')
             })
         
        -    it("should pass negated if selector does not contain given selector", function() {
        -      expect($('#sandbox span')).not.toBeMatchedBy('#js-match-not');
        +    it("should pass negated if selector does not contain given selector", function () {
        +      expect($('#sandbox span')).not.toBeMatchedBy('#js-match-not')
             })
           })
         
        -  describe("toBeDisabled", function() {
        -    beforeEach(function() {
        +  describe("toBeDisabled", function () {
        +    beforeEach(function () {
               setFixtures('\
                 \n\
                 ')
             })
         
        -    it("should pass on disabled element", function() {
        +    it("should pass on disabled element", function () {
               expect($('#disabled')).toBeDisabled()
               expect($('#disabled').get(0)).toBeDisabled()
             })
         
        -    it("should pass negated on not selected element", function() {
        +    it("should pass negated on not selected element", function () {
               expect($('#enabled')).not.toBeDisabled()
               expect($('#enabled').get(0)).not.toBeDisabled()
             })
           })
         
        -  describe("toBeFocused", function() {
        -    beforeEach(function() {
        +  describe("toBeFocused", function () {
        +    beforeEach(function () {
               setFixtures('')
             })
         
        -    it("should pass on focused element", function() {
        +    it("should pass on focused element", function () {
               var el = $("#focused").focus()
               expect(el).toBeFocused()
             })
         
        -    it("should pass negated on not focused element", function() {
        +    it("should pass negated on not focused element", function () {
               var el = $("#focused")
               expect(el).not.toBeFocused()
             })
           })
         
        -  describe('toHaveBeenTriggeredOn', function() {
        -    beforeEach(function() {
        +  describe('toHaveBeenTriggeredOn', function () {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
               spyOnEvent($('#clickme'), 'click')
               spyOnEvent(document, 'click')
               spyOnEvent($('#otherlink'), 'click')
             })
         
        -    it('should pass if the event was triggered on the object', function() {
        +    it('should pass if the event was triggered on the object', function () {
               $('#clickme').click()
               expect('click').toHaveBeenTriggeredOn($('#clickme'))
               expect('click').toHaveBeenTriggeredOn('#clickme')
             })
         
        -    it('should pass if the event was triggered on document', function() {
        +    it('should pass if the event was triggered on document', function () {
               $(document).click()
               expect('click').toHaveBeenTriggeredOn($(document))
               expect('click').toHaveBeenTriggeredOn(document)
             })
         
        -    it('should pass if the event was triggered on a descendant of document', function() {
        +    it('should pass if the event was triggered on a descendant of document', function () {
               $('#clickme').click()
               expect('click').toHaveBeenTriggeredOn($(document))
               expect('click').toHaveBeenTriggeredOn(document)
             })
         
        -    it('should pass negated if the event was never triggered', function() {
        +    it('should pass negated if the event was never triggered', function () {
               expect('click').not.toHaveBeenTriggeredOn($('#clickme'))
               expect('click').not.toHaveBeenTriggeredOn('#clickme')
             })
         
        -    it('should pass negated if the event was triggered on another non-descendant object', function() {
        +    it('should pass negated if the event was triggered on another non-descendant object', function () {
               $('#otherlink').click()
               expect('click').not.toHaveBeenTriggeredOn($('#clickme'))
               expect('click').not.toHaveBeenTriggeredOn('#clickme')
             })
           })
         
        -  describe('toHaveBeenTriggeredOnAndWith', function() {
        -    beforeEach(function() {
        +  describe('toHaveBeenTriggeredOnAndWith', function () {
        +    beforeEach(function () {
               spyOnEvent(document, 'event')
             })
         
        -    describe("when extra parameter is an object", function() {
        -      it('should pass if the event was triggered on the object with expected arguments', function() {
        +    describe("when extra parameter is an object", function () {
        +      it('should pass if the event was triggered on the object with expected arguments', function () {
                 $(document).trigger('event', { key1: "value1", key2: "value2" })
                 expect('event').toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
               })
         
        -      it('should pass negated if the event was never triggered', function() {
        +      it('should pass negated if the event was never triggered', function () {
                 expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
               })
         
        -      it('should pass negated if the event was triggered on another non-descendant object', function() {
        +      it('should pass negated if the event was triggered on another non-descendant object', function () {
                 $(window).trigger('event', { key1: "value1", key2: "value2" })
                 expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
               })
         
        -      it('should pass negated if the event was triggered but the arguments do not match with the expected arguments', function() {
        +      it('should pass negated if the event was triggered but the arguments do not match with the expected arguments', function () {
                 $(document).trigger('event', { key1: "value1" })
                 expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
                 $(document).trigger('event', { key1: "value1", key2: "value2" })
        @@ -1047,22 +1047,22 @@ describe("jQuery matchers", function() {
               })
             })
         
        -    describe("when extra parameter is an array", function() {
        -      it('should pass if the event was triggered on the object with expected arguments', function() {
        +    describe("when extra parameter is an array", function () {
        +      it('should pass if the event was triggered on the object with expected arguments', function () {
                 $(document).trigger('event', [1, 2])
                 expect('event').toHaveBeenTriggeredOnAndWith(document, [1, 2])
               })
         
        -      it('should pass negated if the event was never triggered', function() {
        +      it('should pass negated if the event was never triggered', function () {
                 expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
               })
         
        -      it('should pass negated if the event was triggered on another non-descendant object', function() {
        +      it('should pass negated if the event was triggered on another non-descendant object', function () {
                 $(window).trigger('event', [1, 2])
                 expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
               })
         
        -      it('should pass negated if the event was triggered but the arguments do not match with the expected arguments', function() {
        +      it('should pass negated if the event was triggered but the arguments do not match with the expected arguments', function () {
                 $(document).trigger('event', [1])
                 expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
                 $(document).trigger('event', [1, 2])
        @@ -1073,29 +1073,29 @@ describe("jQuery matchers", function() {
             })
           })
         
        -  describe('toHaveBeenTriggered', function() {
        +  describe('toHaveBeenTriggered', function () {
             var spyEvents = {}
        -    beforeEach(function() {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
               spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
               spyEvents['#otherlink'] = spyOnEvent($('#otherlink'), 'click')
             })
         
        -    it('should pass if the event was triggered on the object', function() {
        +    it('should pass if the event was triggered on the object', function () {
               $('#clickme').click()
               expect(spyEvents['#clickme']).toHaveBeenTriggered()
             })
         
        -    it('should pass negated if the event was never triggered', function() {
        +    it('should pass negated if the event was never triggered', function () {
               expect(spyEvents['#clickme']).not.toHaveBeenTriggered()
             })
         
        -    it('should pass negated if the event was triggered on another non-descendant object', function() {
        +    it('should pass negated if the event was triggered on another non-descendant object', function () {
               $('#otherlink').click()
               expect(spyEvents['#clickme']).not.toHaveBeenTriggered()
             })
         
        -    it('should pass negated if the spy event was reset', function(){
        +    it('should pass negated if the spy event was reset', function (){
               $('#clickme').click()
               expect('click').toHaveBeenTriggeredOn($('#clickme'))
               expect('click').toHaveBeenTriggeredOn('#clickme')
        @@ -1107,15 +1107,15 @@ describe("jQuery matchers", function() {
             })
           })
         
        -  describe('toHaveBeenPreventedOn', function() {
        -    beforeEach(function() {
        +  describe('toHaveBeenPreventedOn', function () {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
               spyOnEvent($('#clickme'), 'click')
               spyOnEvent($('#otherlink'), 'click')
             })
         
        -    it('should pass if the event was prevented on the object', function() {
        -      $('#clickme').bind('click', function(event) {
        +    it('should pass if the event was prevented on the object', function () {
        +      $('#clickme').bind('click', function (event) {
                 event.preventDefault()
               })
               $('#clickme').click()
        @@ -1123,14 +1123,14 @@ describe("jQuery matchers", function() {
               expect('click').toHaveBeenPreventedOn('#clickme')
             })
         
        -    it('should pass negated if the event was never prevented', function() {
        +    it('should pass negated if the event was never prevented', function () {
               $('#clickme').click()
               expect('click').not.toHaveBeenPreventedOn($('#clickme'))
               expect('click').not.toHaveBeenPreventedOn('#clickme')
             })
         
        -    it('should pass negated if the event was prevented on another non-descendant object', function() {
        -      $('#otherlink').bind('click', function(event) {
        +    it('should pass negated if the event was prevented on another non-descendant object', function () {
        +      $('#otherlink').bind('click', function (event) {
                 event.preventDefault()
               })
               $('#clickme').click()
        @@ -1138,50 +1138,50 @@ describe("jQuery matchers", function() {
             })
           })
         
        -  describe('toHaveBeenPrevented', function() {
        +  describe('toHaveBeenPrevented', function () {
             var spyEvents = {}
        -    beforeEach(function() {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
               spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
               spyEvents['#otherlink'] = spyOnEvent($('#otherlink'), 'click')
             })
         
        -    it('should pass if the event was prevented on the object', function() {
        -      $('#clickme').bind('click', function(event) {
        +    it('should pass if the event was prevented on the object', function () {
        +      $('#clickme').bind('click', function (event) {
                 event.preventDefault()
               })
               $('#clickme').click()
               expect(spyEvents['#clickme']).toHaveBeenPrevented()
             })
         
        -    it('should pass negated if the event was never prevented', function() {
        +    it('should pass negated if the event was never prevented', function () {
               $('#clickme').click()
               expect(spyEvents['#clickme']).not.toHaveBeenPrevented()
             })
         
        -    it('should pass negated if the event was prevented on another non-descendant object', function() {
        -      $('#otherlink').bind('click', function(event) {
        +    it('should pass negated if the event was prevented on another non-descendant object', function () {
        +      $('#otherlink').bind('click', function (event) {
                 event.preventDefault()
               })
               $('#clickme').click()
               expect(spyEvents['#clickme']).not.toHaveBeenPrevented()
             })
         
        -    it('should pass negated if nothing was triggered', function() {
        +    it('should pass negated if nothing was triggered', function () {
               expect(spyEvents['#clickme']).not.toHaveBeenPrevented()
             })
         
           })
         
        -  describe('toHaveBeenStoppedOn', function() {
        -    beforeEach(function() {
        +  describe('toHaveBeenStoppedOn', function () {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
               spyOnEvent($('#clickme'), 'click')
               spyOnEvent($('#otherlink'), 'click')
             })
         
        -    it('should pass if the event was stopped on the object', function() {
        -      $('#clickme').bind('click', function(event) {
        +    it('should pass if the event was stopped on the object', function () {
        +      $('#clickme').bind('click', function (event) {
                 event.stopPropagation()
               })
               $('#clickme').click()
        @@ -1189,14 +1189,14 @@ describe("jQuery matchers", function() {
               expect('click').toHaveBeenStoppedOn('#clickme')
             })
         
        -    it('should pass negated if the event was never stopped', function() {
        +    it('should pass negated if the event was never stopped', function () {
               $('#clickme').click()
               expect('click').not.toHaveBeenStoppedOn($('#clickme'))
               expect('click').not.toHaveBeenStoppedOn('#clickme')
             })
         
        -    it('should pass negated if the event was stopped on another non-descendant object', function() {
        -      $('#otherlink').bind('click', function(event) {
        +    it('should pass negated if the event was stopped on another non-descendant object', function () {
        +      $('#otherlink').bind('click', function (event) {
                 event.stopPropagation()
               })
               $('#clickme').click()
        @@ -1204,75 +1204,75 @@ describe("jQuery matchers", function() {
             })
           })
         
        -  describe('toHaveBeenStopped', function() {
        +  describe('toHaveBeenStopped', function () {
             var spyEvents = {}
        -    beforeEach(function() {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
               spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
               spyEvents['#otherlink'] = spyOnEvent($('#otherlink'), 'click')
             })
         
        -    it('should pass if the event was stopped on the object', function() {
        -      $('#clickme').bind('click', function(event) {
        +    it('should pass if the event was stopped on the object', function () {
        +      $('#clickme').bind('click', function (event) {
                 event.stopPropagation()
               })
               $('#clickme').click()
               expect(spyEvents['#clickme']).toHaveBeenStopped()
             })
         
        -    it('should pass negated if the event was never stopped', function() {
        +    it('should pass negated if the event was never stopped', function () {
               $('#clickme').click()
               expect(spyEvents['#clickme']).not.toHaveBeenStopped()
             })
         
        -    it('should pass negated if the event was stopped on another non-descendant object', function() {
        -      $('#otherlink').bind('click', function(event) {
        +    it('should pass negated if the event was stopped on another non-descendant object', function () {
        +      $('#otherlink').bind('click', function (event) {
                 event.stopPropagation()
               })
               $('#clickme').click()
               expect(spyEvents['#clickme']).not.toHaveBeenStopped()
             })
         
        -    it('should pass negated if nothing was triggered', function() {
        +    it('should pass negated if nothing was triggered', function () {
               expect(spyEvents['#clickme']).not.toHaveBeenStopped()
             })
           })
         
        -  describe('toHandle', function() {
        +  describe('toHandle', function () {
             var handler
        -    beforeEach(function() {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
        -      handler = function(){}
        +      handler = function (){}
             })
         
        -    it("should handle events on the window object", function(){
        +    it("should handle events on the window object", function (){
               $(window).bind("resize", handler)
               expect($(window)).toHandle("resize")
             })
         
        -    it('should pass if the event is bound', function() {
        +    it('should pass if the event is bound', function () {
               $('#clickme').bind("click", handler)
               expect($('#clickme')).toHandle("click")
               expect($('#clickme').get(0)).toHandle("click")
             })
         
        -    it('should pass if the event is not bound', function() {
        +    it('should pass if the event is not bound', function () {
               expect($('#clickme')).not.toHandle("click")
               expect($('#clickme').get(0)).not.toHandle("click")
             })
         
        -    it('should pass if the namespaced event is bound', function(){
        +    it('should pass if the namespaced event is bound', function (){
               $('#clickme').bind("click", handler); //another event for the click array
               $('#clickme').bind("click.NameSpace", handler)
               expect($('#clickme')).toHandle("click.NameSpace")
             })
         
        -    it('should not fail when events is empty', function() {
        -      $('#clickme').change(function() { })
        +    it('should not fail when events is empty', function () {
        +      $('#clickme').change(function () { })
               expect($('#clickme')).not.toHandle('click')
             })
         
        -    it('should recognize an event with multiple namespaces', function(){
        +    it('should recognize an event with multiple namespaces', function (){
               $('#clickme').bind("click.NSone.NStwo.NSthree", handler)
               expect($('#clickme')).toHandle("click.NSone")
               expect($('#clickme')).toHandle("click.NStwo")
        @@ -1282,117 +1282,117 @@ describe("jQuery matchers", function() {
               expect($('#clickme')).toHandle("click")
             })
         
        -    it('should pass if a namespaced event is not bound', function() {
        +    it('should pass if a namespaced event is not bound', function () {
               $('#clickme').bind("click", handler); //non namespaced event
               $('#clickme').bind("click.OtherNameSpace", handler); //different namespaced event
               expect($('#clickme')).not.toHandle("click.NameSpace")
             })
         
        -    it('should handle event on any object', function(){
        -      var object = new function(){}
        -      $(object).bind('click', function(){})
        +    it('should handle event on any object', function (){
        +      var object = new function (){}
        +      $(object).bind('click', function (){})
               expect($(object)).toHandle('click')
             })
           })
         
        -  describe('toHandleWith', function() {
        -    beforeEach(function() {
        +  describe('toHandleWith', function () {
        +    beforeEach(function () {
               setFixtures(sandbox().html('Click Me Other Link'))
             })
         
        -    it('should pass if the event is bound with the given handler', function() {
        -      var handler = function(){}
        +    it('should pass if the event is bound with the given handler', function () {
        +      var handler = function (){}
               $('#clickme').bind("click", handler)
               expect($('#clickme')).toHandleWith("click", handler)
               expect($('#clickme').get(0)).toHandleWith("click", handler)
             })
         
        -    it('should pass if the event is not bound with the given handler', function() {
        -      var handler = function(){}
        +    it('should pass if the event is not bound with the given handler', function () {
        +      var handler = function (){}
               $('#clickme').bind("click", handler)
         
        -      var aDifferentHandler = function(){}
        +      var aDifferentHandler = function (){}
               expect($('#clickme')).not.toHandleWith("click", aDifferentHandler)
               expect($('#clickme').get(0)).not.toHandleWith("click", aDifferentHandler)
             })
         
        -    it('should pass if the event is not bound at all', function() {
        +    it('should pass if the event is not bound at all', function () {
               expect($('#clickme')).not.toHandle("click")
               expect($('#clickme').get(0)).not.toHandle("click")
             })
         
        -    it("should pass if the event on window is bound with the given handler", function(){
        -      var handler = function(){}
        +    it("should pass if the event on window is bound with the given handler", function (){
        +      var handler = function (){}
               $(window).bind("resize", handler)
               expect($(window)).toHandleWith("resize", handler)
             })
         
        -    it("should pass if the event on any object is bound with the given handler", function(){
        -      var object = new function(){}
        -      var handler = function(){}
        +    it("should pass if the event on any object is bound with the given handler", function (){
        +      var object = new function (){}
        +      var handler = function (){}
               $(object).bind('click', handler)
               expect($(object)).toHandleWith('click', handler)
             })
         
        -    it("should pass if the namespaced event is bound with the given handler", function() {
        -      var handler = function(){}
        +    it("should pass if the namespaced event is bound with the given handler", function () {
        +      var handler = function (){}
               $('#clickme').bind("click.namespaced", handler)
               expect($('#clickme')).toHandleWith("click.namespaced", handler)
               expect($('#clickme').get(0)).toHandleWith("click.namespaced", handler)
             })
         
        -    it('should pass if the namespaced event is not bound with the given handler', function() {
        -      var handler = function(){}
        +    it('should pass if the namespaced event is not bound with the given handler', function () {
        +      var handler = function (){}
               $('#clickme').bind("click", handler)
         
        -      var aDifferentHandler = function(){}
        +      var aDifferentHandler = function (){}
               expect($('#clickme')).not.toHandleWith("click.namespaced", aDifferentHandler)
               expect($('#clickme').get(0)).not.toHandleWith("click.namespaced", aDifferentHandler)
             })
         
        -    it('should pass if the namespaced event is not bound at all', function() {
        +    it('should pass if the namespaced event is not bound at all', function () {
               expect($('#clickme')).not.toHandle("click.namespaced")
               expect($('#clickme').get(0)).not.toHandle("click.namespaced")
             })
         
        -    it("should pass if the namespaced event on window is bound with the given handler", function(){
        -      var handler = function(){}
        +    it("should pass if the namespaced event on window is bound with the given handler", function (){
        +      var handler = function (){}
               $(window).bind("resize.namespaced", handler)
               expect($(window)).toHandleWith("resize.namespaced", handler)
             })
         
        -    it("should pass if the namespaced event on any object is bound with the given handler", function(){
        -      var object = new function(){}
        -      var handler = function(){}
        +    it("should pass if the namespaced event on any object is bound with the given handler", function (){
        +      var object = new function (){}
        +      var handler = function (){}
               $(object).bind('click.namespaced', handler)
               expect($(object)).toHandleWith('click.namespaced', handler)
             })
           })
         })
         
        -describe("jasmine.StyleFixtures", function() {
        +describe("jasmine.StyleFixtures", function () {
           var ajaxData = 'some ajax data'
           var fixtureUrl = 'some_url'
           var anotherFixtureUrl = 'another_url'
        -  var fixturesContainer = function() {
        +  var fixturesContainer = function () {
             return $('head style').last()
           }
         
        -  beforeEach(function() {
        +  beforeEach(function () {
             jasmine.getStyleFixtures().clearCache()
        -    spyOn(jasmine.StyleFixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function(relativeUrl){
        +    spyOn(jasmine.StyleFixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function (relativeUrl){
               this.fixturesCache_[relativeUrl] = ajaxData
             })
           })
         
        -  describe("default initial config values", function() {
        -    it("should set 'spec/javascripts/fixtures' as the default style fixtures path", function() {
        +  describe("default initial config values", function () {
        +    it("should set 'spec/javascripts/fixtures' as the default style fixtures path", function () {
               expect(jasmine.getStyleFixtures().fixturesPath).toEqual('spec/javascripts/fixtures')
             })
           })
         
        -  describe("load", function() {
        -    it("should insert CSS fixture within style tag into HEAD", function() {
        +  describe("load", function () {
        +    it("should insert CSS fixture within style tag into HEAD", function () {
               var stylesNumOld = $('head style').length
         
               jasmine.getStyleFixtures().load(fixtureUrl)
        @@ -1400,28 +1400,28 @@ describe("jasmine.StyleFixtures", function() {
               expect(fixturesContainer().html()).toEqual(ajaxData)
             })
         
        -    it("should insert duplicated CSS fixture into one style tag when the same url is provided twice in a single call", function() {
        +    it("should insert duplicated CSS fixture into one style tag when the same url is provided twice in a single call", function () {
               jasmine.getStyleFixtures().load(fixtureUrl, fixtureUrl)
               expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
             })
         
        -    it("should insert merged CSS of two fixtures into one style tag when two different urls are provided in a single call", function() {
        +    it("should insert merged CSS of two fixtures into one style tag when two different urls are provided in a single call", function () {
               jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
               expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
             })
         
        -    it("should have shortcut global method loadStyleFixtures", function() {
        +    it("should have shortcut global method loadStyleFixtures", function () {
               loadStyleFixtures(fixtureUrl, anotherFixtureUrl)
               expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
             })
           })
         
        -  describe("appendLoad", function() {
        -    beforeEach(function(){
        +  describe("appendLoad", function () {
        +    beforeEach(function (){
               ajaxData = 'some ajax data'
             })
         
        -    it("should insert CSS fixture within style tag into HEAD", function() {
        +    it("should insert CSS fixture within style tag into HEAD", function () {
               var stylesNumOld = $('head style').length
         
               jasmine.getStyleFixtures().appendLoad(fixtureUrl)
        @@ -1429,68 +1429,68 @@ describe("jasmine.StyleFixtures", function() {
               expect(fixturesContainer().html()).toEqual(ajaxData)
             })
         
        -    it("should insert duplicated CSS fixture into one style tag when the same url is provided twice in a single call", function() {
        +    it("should insert duplicated CSS fixture into one style tag when the same url is provided twice in a single call", function () {
               jasmine.getStyleFixtures().appendLoad(fixtureUrl, fixtureUrl)
               expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
             })
         
        -    it("should insert merged CSS of two fixtures into one style tag when two different urls are provided in a single call", function() {
        +    it("should insert merged CSS of two fixtures into one style tag when two different urls are provided in a single call", function () {
               jasmine.getStyleFixtures().appendLoad(fixtureUrl, anotherFixtureUrl)
               expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
             })
         
        -    it("should have shortcut global method appendLoadStyleFixtures", function() {
        +    it("should have shortcut global method appendLoadStyleFixtures", function () {
               appendLoadStyleFixtures(fixtureUrl, anotherFixtureUrl)
               expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
             })
         
        -    describe("with a prexisting fixture",function(){
        -      beforeEach(function() {
        +    describe("with a prexisting fixture",function (){
        +      beforeEach(function () {
                 jasmine.getStyleFixtures().appendLoad(fixtureUrl)
               })
         
        -      it("should add new content within new style tag in HEAD", function() {
        +      it("should add new content within new style tag in HEAD", function () {
                 jasmine.getStyleFixtures().appendLoad(anotherFixtureUrl)
                 expect(fixturesContainer().html()).toEqual(ajaxData)
               })
         
        -      it("should not delete prexisting fixtures", function() {
        +      it("should not delete prexisting fixtures", function () {
                 jasmine.getStyleFixtures().appendLoad(anotherFixtureUrl)
                 expect(fixturesContainer().prev().html()).toEqual(ajaxData)
               })
             })
           })
         
        -  describe("preload", function() {
        -    describe("load after preload", function() {
        -      it("should go from cache", function() {
        +  describe("preload", function () {
        +    describe("load after preload", function () {
        +      it("should go from cache", function () {
                 jasmine.getStyleFixtures().preload(fixtureUrl, anotherFixtureUrl)
                 jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
                 expect(jasmine.StyleFixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2)
               })
         
        -      it("should return correct CSSs", function() {
        +      it("should return correct CSSs", function () {
                 jasmine.getStyleFixtures().preload(fixtureUrl, anotherFixtureUrl)
                 jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
                 expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
               })
             })
         
        -    it("should not preload the same fixture twice", function() {
        +    it("should not preload the same fixture twice", function () {
               jasmine.getStyleFixtures().preload(fixtureUrl, fixtureUrl)
               expect(jasmine.StyleFixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1)
             })
         
        -    it("should have shortcut global method preloadStyleFixtures", function() {
        +    it("should have shortcut global method preloadStyleFixtures", function () {
               preloadStyleFixtures(fixtureUrl, anotherFixtureUrl)
               expect(jasmine.StyleFixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2)
             })
           })
         
        -  describe("set", function() {
        +  describe("set", function () {
             var css = 'body { color: red }'
         
        -    it("should insert CSS within style tag into HEAD", function() {
        +    it("should insert CSS within style tag into HEAD", function () {
               var stylesNumOld = $('head style').length
         
               jasmine.getStyleFixtures().set(css)
        @@ -1498,16 +1498,16 @@ describe("jasmine.StyleFixtures", function() {
               expect(fixturesContainer().html()).toEqual(css)
             })
         
        -    it("should have shortcut global method setStyleFixtures", function() {
        +    it("should have shortcut global method setStyleFixtures", function () {
               setStyleFixtures(css)
               expect(fixturesContainer().html()).toEqual(css)
             })
           })
         
        -  describe("appendSet",function(){
        +  describe("appendSet",function (){
             var css = 'body { color: red }'
         
        -    it("should insert CSS within style tag into HEAD", function() {
        +    it("should insert CSS within style tag into HEAD", function () {
               var stylesNumOld = $('head style').length
         
               jasmine.getStyleFixtures().appendSet(css)
        @@ -1515,30 +1515,30 @@ describe("jasmine.StyleFixtures", function() {
               expect(fixturesContainer().html()).toEqual(css)
             })
         
        -    it("should have shortcut global method appendSetStyleFixtures", function() {
        +    it("should have shortcut global method appendSetStyleFixtures", function () {
               appendSetStyleFixtures(css)
               expect(fixturesContainer().html()).toEqual(css)
             })
         
        -    describe("when fixture container exists", function() {
        -      beforeEach(function() {
        +    describe("when fixture container exists", function () {
        +      beforeEach(function () {
                 jasmine.getStyleFixtures().appendSet(css)
               })
         
        -      it("should add new content within new style tag in HEAD", function() {
        +      it("should add new content within new style tag in HEAD", function () {
                 jasmine.getStyleFixtures().appendSet(css)
                 expect(fixturesContainer().html()).toEqual(css)
               })
         
        -      it("should not delete prexisting fixtures", function() {
        +      it("should not delete prexisting fixtures", function () {
                 jasmine.getStyleFixtures().appendSet(css)
                 expect(fixturesContainer().prev().html()).toEqual(css)
               })
             })
           })
         
        -  describe("cleanUp", function() {
        -    it("should remove CSS fixtures from DOM", function() {
        +  describe("cleanUp", function () {
        +    it("should remove CSS fixtures from DOM", function () {
               var stylesNumOld = $('head style').length
         
               jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
        @@ -1548,38 +1548,38 @@ describe("jasmine.StyleFixtures", function() {
             })
           })
         
        -  describe("automatic DOM clean-up between tests", function() {
        +  describe("automatic DOM clean-up between tests", function () {
             var stylesNumOld = $('head style').length
         
             // WARNING: this test must be invoked first (before 'SECOND TEST')!
        -    it("FIRST TEST: should pollute the DOM", function() {
        +    it("FIRST TEST: should pollute the DOM", function () {
               jasmine.getStyleFixtures().load(fixtureUrl)
               expect($('head style').length).toEqual(stylesNumOld + 1)
             })
         
             // WARNING: this test must be invoked second (after 'FIRST TEST')!
        -    it("SECOND TEST: should see the DOM in a blank state", function() {
        +    it("SECOND TEST: should see the DOM in a blank state", function () {
               expect($('head style').length).toEqual(stylesNumOld)
             })
           })
         })
         
        -describe("jasmine.StyleFixtures using real AJAX call", function() {
        +describe("jasmine.StyleFixtures using real AJAX call", function () {
           var defaultFixturesPath
         
        -  beforeEach(function() {
        +  beforeEach(function () {
             defaultFixturesPath = jasmine.getStyleFixtures().fixturesPath
             jasmine.getStyleFixtures().fixturesPath = 'spec/fixtures'
           })
         
        -  afterEach(function() {
        +  afterEach(function () {
             jasmine.getStyleFixtures().fixturesPath = defaultFixturesPath
           })
         
        -  describe("when fixture file exists", function() {
        +  describe("when fixture file exists", function () {
             var fixtureUrl = "real_non_mocked_fixture_style.css"
         
        -    it("should load content of fixture file", function() {
        +    it("should load content of fixture file", function () {
               jasmine.getStyleFixtures().load(fixtureUrl)
               expect($('head style').last().html()).toEqual('body { background: red; }')
             })
        @@ -1587,20 +1587,20 @@ describe("jasmine.StyleFixtures using real AJAX call", function() {
         })
         
         
        -describe("jasmine.JSONFixtures", function() {
        +describe("jasmine.JSONFixtures", function () {
           var ajaxData = {a:1, b:2, arr: [1,2,'stuff'], hsh: { blurp: 8, blop: 'blip' }}
           var moreAjaxData = [1,2,'stuff']
           var fixtureUrl = 'some_json'
           var anotherFixtureUrl = 'another_json'
        -  var _sortedKeys = function(obj) {
        +  var _sortedKeys = function (obj) {
             var arr = []
             for(var k in obj) arr.push(k)
             return arr.sort()
           }
         
        -  beforeEach(function() {
        +  beforeEach(function () {
             jasmine.getJSONFixtures().clearCache()
        -    spyOn(jasmine.JSONFixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function(relativeUrl){
        +    spyOn(jasmine.JSONFixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function (relativeUrl){
               fakeData = {}
               // we put the data directly here, instead of using the variables to simulate rereading the file
               fakeData[fixtureUrl] = {a:1, b:2, arr: [1,2,'stuff'], hsh: { blurp: 8, blop: 'blip' }}
        @@ -1609,32 +1609,32 @@ describe("jasmine.JSONFixtures", function() {
             })
           })
         
        -  describe("default initial config values", function() {
        -    it("should set 'spec/javascripts/fixtures/json' as the default style fixtures path", function() {
        +  describe("default initial config values", function () {
        +    it("should set 'spec/javascripts/fixtures/json' as the default style fixtures path", function () {
               expect(jasmine.getJSONFixtures().fixturesPath).toEqual('spec/javascripts/fixtures/json')
             })
           })
         
        -  describe("load", function() {
        -    it("should load the JSON data under the key 'fixture_url'", function() {
        +  describe("load", function () {
        +    it("should load the JSON data under the key 'fixture_url'", function () {
               data = jasmine.getJSONFixtures().load(fixtureUrl)
               expect(_sortedKeys(data)).toEqual([fixtureUrl])
               expect(data[fixtureUrl]).toEqual(ajaxData)
             })
         
        -    it("should load the JSON data under the key 'fixture_url', even if it's loaded twice in one call", function() {
        +    it("should load the JSON data under the key 'fixture_url', even if it's loaded twice in one call", function () {
               data = jasmine.getJSONFixtures().load(fixtureUrl, fixtureUrl)
               expect(_sortedKeys(data)).toEqual([fixtureUrl])
             })
         
        -    it("should load the JSON data under 2 keys given two files in a single call", function() {
        +    it("should load the JSON data under 2 keys given two files in a single call", function () {
               data = jasmine.getJSONFixtures().load(anotherFixtureUrl, fixtureUrl)
               expect(_sortedKeys(data)).toEqual([anotherFixtureUrl, fixtureUrl])
               expect(data[anotherFixtureUrl]).toEqual(moreAjaxData)
               expect(data[fixtureUrl]).toEqual(ajaxData)
             })
         
        -    it("should have shortcut global method loadJSONFixtures", function() {
        +    it("should have shortcut global method loadJSONFixtures", function () {
               data = loadJSONFixtures(fixtureUrl, anotherFixtureUrl)
               expect(_sortedKeys(data)).toEqual([anotherFixtureUrl, fixtureUrl])
               expect(data[anotherFixtureUrl]).toEqual(moreAjaxData)
        @@ -1642,77 +1642,77 @@ describe("jasmine.JSONFixtures", function() {
             })
           })
         
        -  describe('getJSONFixture', function() {
        -    it("fetches the fixture you ask for", function() {
        +  describe('getJSONFixture', function () {
        +    it("fetches the fixture you ask for", function () {
               expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData)
               expect(getJSONFixture(anotherFixtureUrl)).toEqual(moreAjaxData)
             })
           })
         
        -  describe("reloading data will restore the fixture data", function() {
        +  describe("reloading data will restore the fixture data", function () {
             var data
        -    beforeEach(function() {
        +    beforeEach(function () {
               data = jasmine.getJSONFixtures().load(anotherFixtureUrl)[anotherFixtureUrl]
             })
             // WARNING: this test must be invoked first (before 'SECOND TEST')!
        -    it("FIRST TEST: should pollute the fixture data", function() {
        +    it("FIRST TEST: should pollute the fixture data", function () {
               data.push('moredata')
               expect(data.length).toEqual(4)
             })
         
             // WARNING: this test must be invoked second (after 'FIRST TEST')!
        -    it("SECOND TEST: should see cleansed JSON fixture data", function() {
        +    it("SECOND TEST: should see cleansed JSON fixture data", function () {
               expect(data.length).toEqual(3)
             })
           })
         })
         
        -describe("jasmine.JSONFixtures using real AJAX call", function() {
        +describe("jasmine.JSONFixtures using real AJAX call", function () {
           var defaultFixturesPath
         
        -  beforeEach(function() {
        +  beforeEach(function () {
             defaultFixturesPath = jasmine.getJSONFixtures().fixturesPath
             jasmine.getJSONFixtures().fixturesPath = 'spec/fixtures/json'
           })
         
        -  afterEach(function() {
        +  afterEach(function () {
             jasmine.getJSONFixtures().fixturesPath = defaultFixturesPath
           })
         
        -  describe("when fixture file exists", function() {
        +  describe("when fixture file exists", function () {
             var fixtureUrl = "jasmine_json_test.json"
         
        -    it("should load content of fixture file", function() {
        +    it("should load content of fixture file", function () {
               data = jasmine.getJSONFixtures().load(fixtureUrl)
               expect(data[fixtureUrl]).toEqual([1,2,3])
             })
           })
         })
         
        -describe("jasmine.Env.equalityTesters_", function() {
        -  describe("jQuery object tester", function() {
        -    beforeEach(function() {
        +describe("jasmine.Env.equalityTesters_", function () {
        +  describe("jQuery object tester", function () {
        +    beforeEach(function () {
               setFixtures(sandbox())
             })
         
        -    it("should equate the same element with different selectors", function() {
        +    it("should equate the same element with different selectors", function () {
               expect($('#sandbox')).toEqual($('div#sandbox'))
             })
         
        -    it("should equate jquery objects that match a set of elements", function() {
        +    it("should equate jquery objects that match a set of elements", function () {
               $('#sandbox').append($('
        ')) $('#sandbox').append($('
        ')) expect($('#sandbox div')).toEqual($('div#sandbox div')) }) - it("should not equate jquery objects that match a set of elements where one has an extra", function() { + it("should not equate jquery objects that match a set of elements where one has an extra", function () { $('#sandbox').append($('
        ')) $('#sandbox').append($('
        ')) $('#sandbox').append($('')) expect($('#sandbox div')).not.toEqual($('div#sandbox div, div#sandbox span')) }) - it("should not equate jquery objects that match a set of elements of the same type where the tag types are the same, but they are not the same DOM elements", function() { + it("should not equate jquery objects that match a set of elements of the same type where the tag types are the same, but they are not the same DOM elements", function () { $('#sandbox').append($('
        ')) $('#sandbox').append($('')) $('#sandbox').append($('
        ')) @@ -1720,10 +1720,10 @@ describe("jasmine.Env.equalityTesters_", function() { expect($('.one')).not.toEqual($('.two').first()) }) - it("should not equate jquery objects that match a set of elements of the same type where one is missing a single element", function() { + it("should not equate jquery objects that match a set of elements of the same type where one is missing a single element", function () { $('#sandbox').append($('
        ')) $('#sandbox').append($('
        ')) expect($('#sandbox div')).not.toEqual($('div#sandbox div').first()) }) }) -}) +}); From 40bfe871e9b0a665a865822611cafbd2b1f47d7f Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 1 Sep 2013 03:04:24 -0500 Subject: [PATCH 26/77] Separate global functions --- lib/jasmine-jquery.js | 566 +++++++++++++++++++++--------------------- 1 file changed, 285 insertions(+), 281 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 0d796ffd..c33169ce 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,92 +1,33 @@ /*! - Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. +Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. - Version 1.5.8 +Version 1.5.8 - /~https://github.com/velesin/jasmine-jquery +/~https://github.com/velesin/jasmine-jquery - Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery +Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ - +function (jasmine, $, global) { "use strict"; - global.readFixtures = function () { - return jasmine.getFixtures().proxyCallTo_('read', arguments) - } - - global.preloadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('preload', arguments) - } - - global.loadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('load', arguments) - } - - global.appendLoadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) - } - - global.setFixtures = function (html) { - return jasmine.getFixtures().proxyCallTo_('set', arguments) - } - - global.appendSetFixtures = function () { - jasmine.getFixtures().proxyCallTo_('appendSet', arguments) - } - - global.sandbox = function (attributes) { - return jasmine.getFixtures().sandbox(attributes) - } - - global.spyOnEvent = function (selector, eventName) { - return jasmine.JQuery.events.spyOn(selector, eventName) - } - - global.preloadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) - } - - global.loadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('load', arguments) - } - - global.appendLoadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) - } - - global.setStyleFixtures = function (html) { - jasmine.getStyleFixtures().proxyCallTo_('set', arguments) - } - - global.appendSetStyleFixtures = function (html) { - jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) - } - - global.loadJSONFixtures = function () { - return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) - } - - global.getJSONFixture = function (url) { - return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] - } ++function (jasmine, $) { "use strict"; jasmine.spiedEventsKey = function (selector, eventName) { return [$(selector).selector, eventName].toString() @@ -390,129 +331,129 @@ for (var prop in css){ if (this.actual.css(prop) !== css[prop]) return false } - return true - }, - - toBeVisible: function () { - return this.actual.is(':visible') - }, - - toBeHidden: function () { - return this.actual.is(':hidden') - }, - - toBeSelected: function () { - return this.actual.is(':selected') - }, - - toBeChecked: function () { - return this.actual.is(':checked') - }, - - toBeEmpty: function () { - return this.actual.is(':empty') - }, - - toExist: function () { - return $(document).find(this.actual).length - }, - - toHaveLength: function (length) { - return this.actual.length === length - }, - - toHaveAttr: function (attributeName, expectedAttributeValue) { - return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) - }, - - toHaveProp: function (propertyName, expectedPropertyValue) { - return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) - }, - - toHaveId: function (id) { - return this.actual.attr('id') == id - }, - - toHaveHtml: function (html) { - return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html) - }, - - toContainHtml: function (html){ - var actualHtml = this.actual.html() - var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) - return (actualHtml.indexOf(expectedHtml) >= 0) - }, - - toHaveText: function (text) { - var trimmedText = $.trim(this.actual.text()) - if (text && $.isFunction(text.test)) { - return text.test(trimmedText) - } else { - return trimmedText == text - } - }, - - toContainText: function (text) { - var trimmedText = $.trim(this.actual.text()) - if (text && $.isFunction(text.test)) { - return text.test(trimmedText) - } else { - return trimmedText.indexOf(text) != -1 - } - }, + return true + }, + + toBeVisible: function () { + return this.actual.is(':visible') + }, + + toBeHidden: function () { + return this.actual.is(':hidden') + }, - toHaveValue: function (value) { - return this.actual.val() === value - }, + toBeSelected: function () { + return this.actual.is(':selected') + }, - toHaveData: function (key, expectedValue) { - return hasProperty(this.actual.data(key), expectedValue) - }, + toBeChecked: function () { + return this.actual.is(':checked') + }, + + toBeEmpty: function () { + return this.actual.is(':empty') + }, - toBe: function (selector) { - return this.actual.is(selector) - }, + toExist: function () { + return $(document).find(this.actual).length + }, - toContain: function (selector) { - return this.actual.find(selector).length - }, + toHaveLength: function (length) { + return this.actual.length === length + }, - toBeMatchedBy: function (selector) { - return this.actual.filter(selector).length - }, + toHaveAttr: function (attributeName, expectedAttributeValue) { + return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) + }, - toBeDisabled: function (selector){ - return this.actual.is(':disabled') - }, + toHaveProp: function (propertyName, expectedPropertyValue) { + return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) + }, - toBeFocused: function (selector) { - return this.actual[0] === this.actual[0].ownerDocument.activeElement - }, + toHaveId: function (id) { + return this.actual.attr('id') == id + }, - toHandle: function (event) { + toHaveHtml: function (html) { + return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html) + }, - var events = $._data(this.actual.get(0), "events") + toContainHtml: function (html){ + var actualHtml = this.actual.html() + var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) + return (actualHtml.indexOf(expectedHtml) >= 0) + }, - if(!events || !event || typeof event !== "string") { - return false - } + toHaveText: function (text) { + var trimmedText = $.trim(this.actual.text()) + if (text && $.isFunction(text.test)) { + return text.test(trimmedText) + } else { + return trimmedText == text + } + }, - var namespaces = event.split(".") - var eventType = namespaces.shift() - var sortedNamespaces = namespaces.slice(0).sort() - var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") + toContainText: function (text) { + var trimmedText = $.trim(this.actual.text()) + if (text && $.isFunction(text.test)) { + return text.test(trimmedText) + } else { + return trimmedText.indexOf(text) != -1 + } + }, - if(events[eventType] && namespaces.length) { - for(var i = 0; i < events[eventType].length; i++) { - var namespace = events[eventType][i].namespace - if(namespaceRegExp.test(namespace)) { - return true + toHaveValue: function (value) { + return this.actual.val() === value + }, + + toHaveData: function (key, expectedValue) { + return hasProperty(this.actual.data(key), expectedValue) + }, + + toBe: function (selector) { + return this.actual.is(selector) + }, + + toContain: function (selector) { + return this.actual.find(selector).length + }, + + toBeMatchedBy: function (selector) { + return this.actual.filter(selector).length + }, + + toBeDisabled: function (selector){ + return this.actual.is(':disabled') + }, + + toBeFocused: function (selector) { + return this.actual[0] === this.actual[0].ownerDocument.activeElement + }, + + toHandle: function (event) { + + var events = $._data(this.actual.get(0), "events") + + if(!events || !event || typeof event !== "string") { + return false + } + + var namespaces = event.split(".") + var eventType = namespaces.shift() + var sortedNamespaces = namespaces.slice(0).sort() + var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") + + if(events[eventType] && namespaces.length) { + for(var i = 0; i < events[eventType].length; i++) { + var namespace = events[eventType][i].namespace + if(namespaceRegExp.test(namespace)) { + return true + } } + } else { + return events[eventType] && events[eventType].length > 0 } - } else { - return events[eventType] && events[eventType].length > 0 - } - }, + }, // tests the existence of a specific event binding + handler toHandleWith: function (eventName, eventHandler) { @@ -521,41 +462,41 @@ for (var i = 0; i < stack.length; i++) { if (stack[i].handler == eventHandler) return true } - return false + return false + } } - } - var hasProperty = function (actualValue, expectedValue) { - if (expectedValue === undefined) return actualValue !== undefined + var hasProperty = function (actualValue, expectedValue) { + if (expectedValue === undefined) return actualValue !== undefined return actualValue == expectedValue - } - - var bindMatcher = function (methodName) { - var builtInMatcher = jasmine.Matchers.prototype[methodName] - - jasmine.JQuery.matchersClass[methodName] = function () { - if (this.actual - && (this.actual instanceof $ - || jasmine.isDomNode(this.actual))) { - this.actual = $(this.actual) - var result = jQueryMatchers[methodName].apply(this, arguments) - var element - if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") - this.actual = jasmine.JQuery.elementToString(this.actual) - return result } - if (builtInMatcher) { - return builtInMatcher.apply(this, arguments) + var bindMatcher = function (methodName) { + var builtInMatcher = jasmine.Matchers.prototype[methodName] + + jasmine.JQuery.matchersClass[methodName] = function () { + if (this.actual + && (this.actual instanceof $ + || jasmine.isDomNode(this.actual))) { + this.actual = $(this.actual) + var result = jQueryMatchers[methodName].apply(this, arguments) + var element + if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") + this.actual = jasmine.JQuery.elementToString(this.actual) + return result + } + + if (builtInMatcher) { + return builtInMatcher.apply(this, arguments) + } + + return false + } } - return false - } - } - - for(var methodName in jQueryMatchers) { - bindMatcher(methodName) - } + for(var methodName in jQueryMatchers) { + bindMatcher(methodName) + } }() beforeEach(function () { @@ -564,8 +505,8 @@ toHaveBeenTriggeredOn: function (selector) { this.message = function () { return [ - "Expected event " + this.actual + " to have been triggered on " + selector, - "Expected event " + this.actual + " not to have been triggered on " + selector + "Expected event " + this.actual + " to have been triggered on " + selector, + "Expected event " + this.actual + " not to have been triggered on " + selector ] } return jasmine.JQuery.events.wasTriggered(selector, this.actual) @@ -577,8 +518,8 @@ selector = this.actual.selector this.message = function () { return [ - "Expected event " + eventName + " to have been triggered on " + selector, - "Expected event " + eventName + " not to have been triggered on " + selector + "Expected event " + eventName + " to have been triggered on " + selector, + "Expected event " + eventName + " not to have been triggered on " + selector ] } return jasmine.JQuery.events.wasTriggered(selector, eventName) @@ -593,79 +534,79 @@ if (wasTriggered) { var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] return [ - "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), - "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) + "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), + "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) ] } else { return [ - "Expected event " + this.actual + " to have been triggered on " + selector, - "Expected event " + this.actual + " not to have been triggered on " + selector + "Expected event " + this.actual + " to have been triggered on " + selector, + "Expected event " + this.actual + " not to have been triggered on " + selector ] } } return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) } }) - this.addMatchers({ - toHaveBeenPreventedOn: function (selector) { - this.message = function () { - return [ - "Expected event " + this.actual + " to have been prevented on " + selector, - "Expected event " + this.actual + " not to have been prevented on " + selector - ] - } - return jasmine.JQuery.events.wasPrevented(selector, this.actual) - } - }) - this.addMatchers({ - toHaveBeenPrevented: function () { - var eventName = this.actual.eventName, - selector = this.actual.selector - this.message = function () { - return [ - "Expected event " + eventName + " to have been prevented on " + selector, - "Expected event " + eventName + " not to have been prevented on " + selector - ] + this.addMatchers({ + toHaveBeenPreventedOn: function (selector) { + this.message = function () { + return [ + "Expected event " + this.actual + " to have been prevented on " + selector, + "Expected event " + this.actual + " not to have been prevented on " + selector + ] + } + return jasmine.JQuery.events.wasPrevented(selector, this.actual) } - return jasmine.JQuery.events.wasPrevented(selector, eventName) - } - }) - this.addMatchers({ - toHaveBeenStoppedOn: function (selector) { - this.message = function () { - return [ - "Expected event " + this.actual + " to have been stopped on " + selector, - "Expected event " + this.actual + " not to have been stopped on " + selector - ] + }) + this.addMatchers({ + toHaveBeenPrevented: function () { + var eventName = this.actual.eventName, + selector = this.actual.selector + this.message = function () { + return [ + "Expected event " + eventName + " to have been prevented on " + selector, + "Expected event " + eventName + " not to have been prevented on " + selector + ] + } + return jasmine.JQuery.events.wasPrevented(selector, eventName) } - return jasmine.JQuery.events.wasStopped(selector, this.actual) - } - }) - this.addMatchers({ - toHaveBeenStopped: function () { - var eventName = this.actual.eventName, - selector = this.actual.selector - this.message = function () { - return [ - "Expected event " + eventName + " to have been stopped on " + selector, - "Expected event " + eventName + " not to have been stopped on " + selector - ] + }) + this.addMatchers({ + toHaveBeenStoppedOn: function (selector) { + this.message = function () { + return [ + "Expected event " + this.actual + " to have been stopped on " + selector, + "Expected event " + this.actual + " not to have been stopped on " + selector + ] + } + return jasmine.JQuery.events.wasStopped(selector, this.actual) } - return jasmine.JQuery.events.wasStopped(selector, eventName) - } - }) - jasmine.getEnv().addEqualityTester(function (a, b) { - if(a instanceof jQuery && b instanceof jQuery) { - if(a.size() != b.size()) { - return jasmine.undefined + }) + this.addMatchers({ + toHaveBeenStopped: function () { + var eventName = this.actual.eventName, + selector = this.actual.selector + this.message = function () { + return [ + "Expected event " + eventName + " to have been stopped on " + selector, + "Expected event " + eventName + " not to have been stopped on " + selector + ] + } + return jasmine.JQuery.events.wasStopped(selector, eventName) } - else if(a.is(b)) { - return true + }) + jasmine.getEnv().addEqualityTester(function (a, b) { + if(a instanceof jQuery && b instanceof jQuery) { + if(a.size() != b.size()) { + return jasmine.undefined + } + else if(a.is(b)) { + return true + } } - } - return jasmine.undefined + return jasmine.undefined - }) + }) }) afterEach(function () { @@ -673,4 +614,67 @@ jasmine.getStyleFixtures().cleanUp() jasmine.JQuery.events.cleanUp() }) -}(window.jasmine, window.jQuery, window); \ No newline at end of file +}(window.jasmine, window.jQuery) + ++function (jasmine, global) { "use strict"; + + global.readFixtures = function () { + return jasmine.getFixtures().proxyCallTo_('read', arguments) + } + + global.preloadFixtures = function () { + jasmine.getFixtures().proxyCallTo_('preload', arguments) + } + + global.loadFixtures = function () { + jasmine.getFixtures().proxyCallTo_('load', arguments) + } + + global.appendLoadFixtures = function () { + jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) + } + + global.setFixtures = function (html) { + return jasmine.getFixtures().proxyCallTo_('set', arguments) + } + + global.appendSetFixtures = function () { + jasmine.getFixtures().proxyCallTo_('appendSet', arguments) + } + + global.sandbox = function (attributes) { + return jasmine.getFixtures().sandbox(attributes) + } + + global.spyOnEvent = function (selector, eventName) { + return jasmine.JQuery.events.spyOn(selector, eventName) + } + + global.preloadStyleFixtures = function () { + jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) + } + + global.loadStyleFixtures = function () { + jasmine.getStyleFixtures().proxyCallTo_('load', arguments) + } + + global.appendLoadStyleFixtures = function () { + jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) + } + + global.setStyleFixtures = function (html) { + jasmine.getStyleFixtures().proxyCallTo_('set', arguments) + } + + global.appendSetStyleFixtures = function (html) { + jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) + } + + global.loadJSONFixtures = function () { + return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) + } + + global.getJSONFixture = function (url) { + return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] + } +}(jasmine, window); From f33d4c51fb8bff1c5058adac0fec3a06c43c706e Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 1 Sep 2013 03:07:24 -0500 Subject: [PATCH 27/77] Documentation goes README.md --- lib/jasmine-jquery.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index c33169ce..ba54828e 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -455,7 +455,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } }, - // tests the existence of a specific event binding + handler toHandleWith: function (eventName, eventHandler) { var normalizedEventName = eventName.split('.')[0] var stack = $._data(this.actual.get(0), "events")[normalizedEventName] From 9d198f1cf92e34685a8f7c07620c7b0489f28150 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 1 Sep 2013 03:14:08 -0500 Subject: [PATCH 28/77] Style --- lib/jasmine-jquery.js | 62 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index ba54828e..52f12c22 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -71,12 +71,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.Fixtures.prototype.read = function () { var htmlChunks = [] - var fixtureUrls = arguments for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) } - return htmlChunks.join('') } @@ -171,22 +169,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.StyleFixtures.prototype.createStyle_ = function (html) { var styleText = $('
        ').html(html).text(), style = $('') - this.fixturesNodes_.push(style) - $('head').append(style) } jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache - jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read - jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_ - jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_ - jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_ - jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ jasmine.getJSONFixtures = function () { @@ -205,9 +196,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.JSONFixtures.prototype.read = function () { var fixtureUrls = arguments + for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { this.getFixtureData_(fixtureUrls[urlIndex]) } + return this.fixturesCache_ } @@ -223,6 +216,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { var self = this var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl + $.ajax({ async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded cache: false, @@ -249,6 +243,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.JQuery.elementToString = function (element) { var domEl = $(element).get(0) + if (domEl === undefined || domEl.cloneNode) return $('
        ').append($(element).clone()).html() else @@ -268,8 +263,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var handler = function (e) { data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) } + $(selector).on(eventName, handler) data.handlers.push(handler) + return { selector: selector, eventName: eventName, @@ -303,14 +300,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }, wasPrevented: function (selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], - e = args ? args[0] : undefined + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + , e = args ? args[0] : undefined + return e && e.isDefaultPrevented() }, wasStopped: function (selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)], - e = args ? args[0] : undefined + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + , e = args ? args[0] : undefined return e && e.isPropagationStopped() }, @@ -381,11 +379,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toContainHtml: function (html){ var actualHtml = this.actual.html() var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) + return (actualHtml.indexOf(expectedHtml) >= 0) }, toHaveText: function (text) { var trimmedText = $.trim(this.actual.text()) + if (text && $.isFunction(text.test)) { return text.test(trimmedText) } else { @@ -395,6 +395,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toContainText: function (text) { var trimmedText = $.trim(this.actual.text()) + if (text && $.isFunction(text.test)) { return text.test(trimmedText) } else { @@ -431,7 +432,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }, toHandle: function (event) { - var events = $._data(this.actual.get(0), "events") if(!events || !event || typeof event !== "string") { @@ -458,15 +458,18 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toHandleWith: function (eventName, eventHandler) { var normalizedEventName = eventName.split('.')[0] var stack = $._data(this.actual.get(0), "events")[normalizedEventName] + for (var i = 0; i < stack.length; i++) { if (stack[i].handler == eventHandler) return true } + return false } } var hasProperty = function (actualValue, expectedValue) { if (expectedValue === undefined) return actualValue !== undefined + return actualValue == expectedValue } @@ -479,9 +482,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. || jasmine.isDomNode(this.actual))) { this.actual = $(this.actual) var result = jQueryMatchers[methodName].apply(this, arguments) - var element + , element + if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") this.actual = jasmine.JQuery.elementToString(this.actual) + return result } @@ -513,22 +518,25 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }) this.addMatchers({ toHaveBeenTriggered: function (){ - var eventName = this.actual.eventName, - selector = this.actual.selector + var eventName = this.actual.eventName + , selector = this.actual.selector + this.message = function () { return [ "Expected event " + eventName + " to have been triggered on " + selector, "Expected event " + eventName + " not to have been triggered on " + selector ] } + return jasmine.JQuery.events.wasTriggered(selector, eventName) } }) this.addMatchers({ toHaveBeenTriggeredOnAndWith: function () { - var selector = arguments[0], - expectedArgs = arguments[1], - wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) + var selector = arguments[0] + , expectedArgs = arguments[1] + , wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) + this.message = function () { if (wasTriggered) { var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] @@ -543,6 +551,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ] } } + return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) } }) @@ -554,19 +563,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "Expected event " + this.actual + " not to have been prevented on " + selector ] } + return jasmine.JQuery.events.wasPrevented(selector, this.actual) } }) this.addMatchers({ toHaveBeenPrevented: function () { - var eventName = this.actual.eventName, - selector = this.actual.selector + var eventName = this.actual.eventName + , selector = this.actual.selector this.message = function () { return [ "Expected event " + eventName + " to have been prevented on " + selector, "Expected event " + eventName + " not to have been prevented on " + selector ] } + return jasmine.JQuery.events.wasPrevented(selector, eventName) } }) @@ -578,13 +589,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "Expected event " + this.actual + " not to have been stopped on " + selector ] } + return jasmine.JQuery.events.wasStopped(selector, this.actual) } }) this.addMatchers({ toHaveBeenStopped: function () { - var eventName = this.actual.eventName, - selector = this.actual.selector + var eventName = this.actual.eventName + , selector = this.actual.selector this.message = function () { return [ "Expected event " + eventName + " to have been stopped on " + selector, @@ -603,8 +615,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. return true } } - return jasmine.undefined + return jasmine.undefined }) }) From dfcaa30e44274e729bab37030cb54de178f52e6b Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 1 Sep 2013 03:16:54 -0500 Subject: [PATCH 29/77] Style --- lib/jasmine-jquery.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 52f12c22..26d808e3 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -71,10 +71,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.Fixtures.prototype.read = function () { var htmlChunks = [] - var fixtureUrls = arguments + , fixtureUrls = arguments + for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) } + return htmlChunks.join('') } @@ -95,6 +97,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var container = $('
        ') .attr('id', this.containerId) .html(html) + $(document.body).append(container) return container } @@ -115,7 +118,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { var url = this.makeFixtureUrl_(relativeUrl) - var request = $.ajax({ + , request = $.ajax({ type: "GET", url: url + "?" + new Date().getTime(), async: false @@ -167,8 +170,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } jasmine.StyleFixtures.prototype.createStyle_ = function (html) { - var styleText = $('
        ').html(html).text(), - style = $('') + var styleText = $('
        ').html(html).text() + , style = $('') + this.fixturesNodes_.push(style) $('head').append(style) } @@ -215,7 +219,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { var self = this - var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl + , url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl $.ajax({ async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded @@ -254,8 +258,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. !function (namespace) { var data = { - spiedEvents: {}, - handlers: [] + spiedEvents: {} + , handlers: [] } namespace.events = { @@ -378,7 +382,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toContainHtml: function (html){ var actualHtml = this.actual.html() - var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) + , expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) return (actualHtml.indexOf(expectedHtml) >= 0) }, @@ -439,13 +443,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var namespaces = event.split(".") - var eventType = namespaces.shift() - var sortedNamespaces = namespaces.slice(0).sort() - var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") + , eventType = namespaces.shift() + , sortedNamespaces = namespaces.slice(0).sort() + , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") if(events[eventType] && namespaces.length) { for(var i = 0; i < events[eventType].length; i++) { var namespace = events[eventType][i].namespace + if(namespaceRegExp.test(namespace)) { return true } @@ -457,7 +462,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toHandleWith: function (eventName, eventHandler) { var normalizedEventName = eventName.split('.')[0] - var stack = $._data(this.actual.get(0), "events")[normalizedEventName] + , stack = $._data(this.actual.get(0), "events")[normalizedEventName] for (var i = 0; i < stack.length; i++) { if (stack[i].handler == eventHandler) return true From eb86cc5f27832284902e9ebcc594c11c0711bde9 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 1 Sep 2013 17:05:02 -0500 Subject: [PATCH 30/77] Glob for lib --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 5c64b54d..0bb78658 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,7 +16,7 @@ module.exports = function (grunt) { }, } , jasmine: { - src: "lib/*.js" + src: "lib/**/*.js" , options: { specs: "spec/**/*.js" , vendor: "vendor/**/*.js" From 2e5bf3c08264ccbf4253d65e9174a9f8b95ff65e Mon Sep 17 00:00:00 2001 From: Wojciech Zawistowski Date: Mon, 2 Sep 2013 12:45:27 +0200 Subject: [PATCH 31/77] added Travis CI status at the end of the Readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b3266cc..60dee79f 100644 --- a/README.md +++ b/README.md @@ -352,4 +352,6 @@ When using [jstd](http://code.google.com/p/js-test-driver/) and the jasmine adap [Travis Jeffery](http://travisjeffery.com/): [Twitter](http://twitter.com/travisjeffery), [GitHub](http://github.com/travisjeffery). -## [Contributing](./CONTRIBUTING.md) \ No newline at end of file +## [Contributing](./CONTRIBUTING.md) + +[![Build Status](https://travis-ci.org/velesin/jasmine-jquery.png)](https://travis-ci.org/velesin/jasmine-jquery) From 511af5278a9d436a56fd52cde5ae7cf4303426a5 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Mon, 2 Sep 2013 16:13:38 -0500 Subject: [PATCH 32/77] Move travis-ci status in the title --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 60dee79f..b5c20ec8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# jasmine-jquery +# jasmine-jquery [![Build Status](https://travis-ci.org/velesin/jasmine-jquery.png)](https://travis-ci.org/velesin/jasmine-jquery) + jasmine-jquery provides two extensions for [Jasmine](http://pivotal.github.com/jasmine/) JavaScript Testing Framework: @@ -353,5 +354,3 @@ When using [jstd](http://code.google.com/p/js-test-driver/) and the jasmine adap [Travis Jeffery](http://travisjeffery.com/): [Twitter](http://twitter.com/travisjeffery), [GitHub](http://github.com/travisjeffery). ## [Contributing](./CONTRIBUTING.md) - -[![Build Status](https://travis-ci.org/velesin/jasmine-jquery.png)](https://travis-ci.org/velesin/jasmine-jquery) From 16ddaada26fb096b81f58b21b9fb3c3202eae03a Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Mon, 2 Sep 2013 16:40:51 -0500 Subject: [PATCH 33/77] Fix requirements for pull-requests --- .issues-guidelines.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.issues-guidelines.js b/.issues-guidelines.js index aade7e66..e222b11f 100644 --- a/.issues-guidelines.js +++ b/.issues-guidelines.js @@ -3,11 +3,6 @@ var assert = require('assert'); module.exports = { 'pull-requests': { - - 'should always be made against -wip branches': function (pull) { - assert.ok(/\-wip$/.test(pull.base.ref)) - }, - 'should always be made from feature branches': function (pull) { assert.notEqual(pull.head.ref, 'master') }, @@ -26,6 +21,7 @@ module.exports = { 'after': function (pull) { if (pull.reporter.stats.failures) { + console.log(pull.reporter) pull.reportFailures(pull.close.bind(pull)) } } From a1f8ab25d54fb87e58dd30779a1b7b7b0f5f519c Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Mon, 2 Sep 2013 16:41:55 -0500 Subject: [PATCH 34/77] Remove console.log --- .issues-guidelines.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.issues-guidelines.js b/.issues-guidelines.js index e222b11f..ad99505a 100644 --- a/.issues-guidelines.js +++ b/.issues-guidelines.js @@ -21,7 +21,6 @@ module.exports = { 'after': function (pull) { if (pull.reporter.stats.failures) { - console.log(pull.reporter) pull.reportFailures(pull.close.bind(pull)) } } From 475ef58e53735f7b803ed7edf7787ea68f8adac1 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 25 Sep 2013 18:44:36 -0500 Subject: [PATCH 35/77] able to expect 'auto' for height css properties when using toHaveCss() (fix #147) --- lib/jasmine-jquery.js | 5 ++++- spec/suites/jasmine-jquery-spec.js | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 26d808e3..f50c106c 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -331,7 +331,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toHaveCss: function (css){ for (var prop in css){ - if (this.actual.css(prop) !== css[prop]) return false + var value = css[prop] + // see issue #147 on gh + ;if (value === 'auto' && this.actual.get(0).style[prop] === 'auto') continue + if (this.actual.css(prop) !== value) return false } return true }, diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index e490fe5e..656b770f 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -565,6 +565,13 @@ describe("jQuery matchers", function () { $("#sandbox").css("margin-left", "20px") expect($("#sandbox")).not.toHaveCss({display: "none", "margin-left": "10px"}) }) + + it("should pass if the css property is auto and you check that property for auto", function (){ + $("#sandbox").css("height", "auto"); + $("#sandbox").css("margin-left", "auto"); + $("#sandbox").css("display", "none"); + expect($("#sandbox")).toHaveCss({height: 'auto', 'margin-left': "0px", display: "none"}); + }) }) describe("toHaveId", function () { From b1296d1b6199b3b4e7c38afaed7c4ff521414849 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 25 Sep 2013 18:47:12 -0500 Subject: [PATCH 36/77] Update History.md for #147 --- HISTORY.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index c33a0529..badce9d2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,9 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. +## v1.5.8 () + - fix toHaveCss() to support expecting a css property be auto (#147) + ## v1.5.1 (April 26, 2013) - adds matcher for jQuery's event.stopPropagation() - adds toHaveLength matcher @@ -10,7 +13,7 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jq - stop toHaveValue from coercing types - fix ajax call that was breaking JSONFixture - fix loadStyleFixtures in IE8 - - makes toBeFocused compatible with PhantomJS + - makes toBeFocused compatible with PhantomJS - updates jQuery to 1.9 - performance improvements - other minor fixes From c457f373eef17531bc853c9659bd651f7230217b Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 25 Sep 2013 18:59:35 -0500 Subject: [PATCH 37/77] Undo #64/15706ec996b8d61547efe64e4e8d6d7312fbf12a (fix #148) --- lib/jasmine-jquery.js | 2 +- spec/suites/jasmine-jquery-spec.js | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index f50c106c..9b2703f8 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -360,7 +360,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }, toExist: function () { - return $(document).find(this.actual).length + return this.actual.length }, toHaveLength: function (length) { diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 656b770f..91fe2312 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -870,13 +870,6 @@ describe("jQuery matchers", function () { expect($('#non-existent-element')).not.toExist() expect($('#non-existent-element').get(0)).not.toExist() }) - - it("should pass on negated removed element", function (){ - setFixtures(sandbox()) - var el = $("#sandbox") - el.remove() - expect(el).not.toExist() - }) }) describe("toHaveLength", function () { From 495ae0d36b9bac8a469bff0b10b997228cfb01b2 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 25 Sep 2013 19:04:03 -0500 Subject: [PATCH 38/77] Update History.md for #148 --- HISTORY.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index badce9d2..35d8fc21 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,8 +2,9 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. -## v1.5.8 () +## v1.5.8 (Sept 14, 2013) - fix toHaveCss() to support expecting a css property be auto (#147) + - fix toExist() for objects outside of the DOM (#64, #148) ## v1.5.1 (April 26, 2013) - adds matcher for jQuery's event.stopPropagation() From 2599717114967786d878a86dfe2549f44394a6be Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 25 Sep 2013 19:33:24 -0500 Subject: [PATCH 39/77] throw error when given fixture is missing (fix #146) --- HISTORY.md | 1 + lib/jasmine-jquery.js | 18 ++++++++++++------ spec/suites/jasmine-jquery-spec.js | 2 -- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 35d8fc21..0cc5b969 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. ## v1.5.8 (Sept 14, 2013) + - fix throw error when loading a fixture that doesn't exist (#146) - fix toHaveCss() to support expecting a css property be auto (#147) - fix toExist() for objects outside of the DOM (#64, #148) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 9b2703f8..9840bee5 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -117,13 +117,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { - var url = this.makeFixtureUrl_(relativeUrl) + var self = this + , url = this.makeFixtureUrl_(relativeUrl) , request = $.ajax({ - type: "GET", - url: url + "?" + new Date().getTime(), - async: false - }) - this.fixturesCache_[relativeUrl] = request.responseText + async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded + cache: false, + url: url, + success: function (data, status, $xhr) { + self.fixturesCache_[relativeUrl] = $xhr.responseText + }, + error: function (jqXHR, status, errorThrown) { + throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + } + }) } jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){ diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 91fe2312..d2d14c43 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -390,7 +390,6 @@ describe("jasmine.Fixtures using real AJAX call", function () { }) }) - /* TODO : start throwing again describe("when fixture file does not exist", function () { var fixtureUrl = "not_existing_fixture" @@ -400,7 +399,6 @@ describe("jasmine.Fixtures using real AJAX call", function () { }).toThrow() }) }) - */ }) From 248521b8c8966b98ee37a337f74a41029ea095a1 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Wed, 25 Sep 2013 19:35:32 -0500 Subject: [PATCH 40/77] v1.5.9 --- HISTORY.md | 2 +- bower.json | 2 +- lib/jasmine-jquery.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 0cc5b969..c751a0bb 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,7 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. -## v1.5.8 (Sept 14, 2013) +## v1.5.9 (Sept 25, 2013) - fix throw error when loading a fixture that doesn't exist (#146) - fix toHaveCss() to support expecting a css property be auto (#147) - fix toExist() for objects outside of the DOM (#64, #148) diff --git a/bower.json b/bower.json index 602ed530..fa1de236 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.8", + "version": "1.5.9", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 9840bee5..5fc42f14 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 1.5.8 +Version 1.5.9 /~https://github.com/velesin/jasmine-jquery diff --git a/package.json b/package.json index 05c9a3d8..cffa941b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.5.8" + , "version": "1.5.9" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { From b8efdb27118e62471fd4828715fb04bcaf02e04b Mon Sep 17 00:00:00 2001 From: micah craig Date: Tue, 1 Oct 2013 12:31:53 -0400 Subject: [PATCH 41/77] Return cached JSON Fixtures on subsequent calls to getJSONFixture requesting the same fixture url. --- lib/jasmine-jquery.js | 4 +++- spec/suites/jasmine-jquery-spec.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 5fc42f14..2ceedacd 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -219,7 +219,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) { - this.loadFixtureIntoCache_(url) + if(! this.fixturesCache_[url]) { + this.loadFixtureIntoCache_(url) + } return this.fixturesCache_[url] } diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index d2d14c43..820f6dde 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -1643,7 +1643,15 @@ describe("jasmine.JSONFixtures", function () { describe('getJSONFixture', function () { it("fetches the fixture you ask for", function () { expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData) + expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_).toHaveBeenCalled() expect(getJSONFixture(anotherFixtureUrl)).toEqual(moreAjaxData) + expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.length).toEqual(2) + }) + it("retrieves from cache on subsequent requests for the same fixture", function () { + expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData) + expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.length).toEqual(1) + expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData) + expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.length).toEqual(1) }) }) From 6128d88c5a3215647e383a84b867f5d2691e9f01 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Tue, 1 Oct 2013 12:10:45 -0500 Subject: [PATCH 42/77] Style --- lib/jasmine-jquery.js | 4 +--- spec/suites/jasmine-jquery-spec.js | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 2ceedacd..2212da07 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -219,9 +219,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) { - if(! this.fixturesCache_[url]) { - this.loadFixtureIntoCache_(url) - } + if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url) return this.fixturesCache_[url] } diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 820f6dde..c9c69600 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -1647,6 +1647,7 @@ describe("jasmine.JSONFixtures", function () { expect(getJSONFixture(anotherFixtureUrl)).toEqual(moreAjaxData) expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.length).toEqual(2) }) + it("retrieves from cache on subsequent requests for the same fixture", function () { expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData) expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.length).toEqual(1) From ab2a134d13873721e796fbf62032a86180e1e2dc Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Tue, 1 Oct 2013 13:04:45 -0500 Subject: [PATCH 43/77] v1.5.91 --- HISTORY.md | 31 +++++++++++++++++-------------- bower.json | 2 +- lib/jasmine-jquery.js | 2 +- package.json | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index c751a0bb..7fbdbd2f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,20 +2,23 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. +## v1.5.91 (Oct 1, 2013) + - fix: caching json data fixtures (#149) + ## v1.5.9 (Sept 25, 2013) - - fix throw error when loading a fixture that doesn't exist (#146) - - fix toHaveCss() to support expecting a css property be auto (#147) - - fix toExist() for objects outside of the DOM (#64, #148) + - fix: throw error when loading a fixture that doesn't exist (#146) + - fix: toHaveCss() to support expecting a css property be auto (#147) + - fix: toExist() for objects outside of the DOM (#64, #148) ## v1.5.1 (April 26, 2013) - - adds matcher for jQuery's event.stopPropagation() - - adds toHaveLength matcher - - adds toContainText matcher - - adds toHaveBeenTriggeredOnAndWith - - stop toHaveValue from coercing types - - fix ajax call that was breaking JSONFixture - - fix loadStyleFixtures in IE8 - - makes toBeFocused compatible with PhantomJS - - updates jQuery to 1.9 - - performance improvements - - other minor fixes + - add: matcher for jQuery's event.stopPropagation() + - add: toHaveLength() matcher + - add: toContainText() matcher + - add: toHaveBeenTriggeredOnAndWith() + - fix: stop toHaveValue from coercing types + - fix: ajax call that was breaking JSONFixture + - fix: loadStyleFixtures() in IE8 + - fix: make toBeFocused() compatible with PhantomJS + - fix: update jQuery to 1.9 + - fix: performance improvements + - fix: other minor fixes diff --git a/bower.json b/bower.json index fa1de236..baf579fb 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.9", + "version": "1.5.91", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 2212da07..538a06a6 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 1.5.9 +Version 1.5.91 /~https://github.com/velesin/jasmine-jquery diff --git a/package.json b/package.json index cffa941b..4f48b058 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.5.9" + , "version": "1.5.91" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { From 90ff0cbf8a797ddfa42406f4ddfa86f590083b7c Mon Sep 17 00:00:00 2001 From: Bob Nadler Date: Wed, 9 Oct 2013 10:35:54 -0400 Subject: [PATCH 44/77] Fix typo in README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5c20ec8..b19b0e20 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ All of above methods have matching global short cuts: - `appendSetFixtures(html)` ``` javascript -var fixture = setFixture('
        foo
        ') +var fixture = setFixtures('
        foo
        ') var post = fixture.find('.post') ``` From de6b0205dab3574e2587629e828220a0c87a9bb6 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Fri, 18 Oct 2013 11:16:50 +0200 Subject: [PATCH 45/77] Don't change the checked property of radio buttons When cloning radio buttons to get the string value, some browsers such as PhantomJS uncheck one of the radio buttons. Fix this by letting elementToString use outerHTML instead of cloning to obtain the HTML. --- lib/jasmine-jquery.js | 8 ++------ spec/suites/jasmine-jquery-spec.js | 8 +++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 538a06a6..04eb5053 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -252,12 +252,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } jasmine.JQuery.elementToString = function (element) { - var domEl = $(element).get(0) - - if (domEl === undefined || domEl.cloneNode) - return $('
        ').append($(element).clone()).html() - else - return element.toString() + var htmlParts = $(element).map(function () { return this.outerHTML; }).toArray() + return htmlParts.join(', ') } jasmine.JQuery.matchersClass = {} diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index c9c69600..7f7b0538 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -817,7 +817,8 @@ describe("jQuery matchers", function () { beforeEach(function () { setFixtures('\ \n\ - ') + \n\ + ') }) it("should pass on checked element", function () { @@ -829,6 +830,11 @@ describe("jQuery matchers", function () { expect($('#not-checked')).not.toBeChecked() expect($('#not-checked').get(0)).not.toBeChecked() }) + + it("shoud not change the checked status of a radio button", function () { + expect($('#radio-checked')).toBeChecked() + expect($('#radio-checked')).toBeChecked() + }) }) describe("toBeEmpty", function () { From fc7664f78aeb2df0a1d91db69cd73cd5fb065826 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Tue, 22 Oct 2013 21:37:10 -0500 Subject: [PATCH 46/77] Fix style --- lib/jasmine-jquery.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 04eb5053..6421ed27 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -252,8 +252,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } jasmine.JQuery.elementToString = function (element) { - var htmlParts = $(element).map(function () { return this.outerHTML; }).toArray() - return htmlParts.join(', ') + return $(element).map(function () { return this.outerHTML; }).toArray().join(', ') } jasmine.JQuery.matchersClass = {} From 0c2013780dfecb3418dd57ce21462eb9a218361d Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Tue, 22 Oct 2013 21:41:19 -0500 Subject: [PATCH 47/77] v1.5.92 --- HISTORY.md | 3 +++ bower.json | 2 +- lib/jasmine-jquery.js | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 7fbdbd2f..65ba053e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,9 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. +## v1.5.92 (Oct 22, 2013) + - fix: cloning radio buttons maintains their checked value + ## v1.5.91 (Oct 1, 2013) - fix: caching json data fixtures (#149) diff --git a/bower.json b/bower.json index baf579fb..0585dc80 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.91", + "version": "1.5.92", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 6421ed27..87d7ef87 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 1.5.91 +Version 1.5.92 /~https://github.com/velesin/jasmine-jquery diff --git a/package.json b/package.json index 4f48b058..8e740b7c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.5.91" + , "version": "1.5.92" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { From 8576b49b45bb233709c7e0785531d51fd4fe468a Mon Sep 17 00:00:00 2001 From: Dario Hamidi Date: Thu, 31 Oct 2013 16:22:52 +0100 Subject: [PATCH 48/77] More accurate description for `toHaveValue` Make it clear that `toHaveValue` should be used for checking the value of textareas (instead of `toContainText`). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b19b0e20..eec9f682 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ jasmine-jquery provides following custom matchers (in alphabetical order): - accepts a String or regular expression - e.g. `expect($('
        some text
        ')).toHaveText('some text')` - `toHaveValue(value)` - - only for tags that have value attribute + - only for elements on which `val` can be called (`input`, `textarea`, etc) - e.g. `expect($('')).toHaveValue('some text')` - `toHaveLength(value)` - e.g. `expect($('ul > li')).toHaveLength(3)` From ceb3da09ac931f2f8da278de0f6d9e3aeef1bff6 Mon Sep 17 00:00:00 2001 From: Polarblau Date: Fri, 15 Nov 2013 12:05:07 +0200 Subject: [PATCH 49/77] Use strict equality check within `hasProperty` (close #155) --- lib/jasmine-jquery.js | 2 +- spec/suites/jasmine-jquery-spec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 87d7ef87..a4305748 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -479,7 +479,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var hasProperty = function (actualValue, expectedValue) { if (expectedValue === undefined) return actualValue !== undefined - return actualValue == expectedValue + return actualValue === expectedValue } var bindMatcher = function (methodName) { diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 7f7b0538..a02d1270 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -763,6 +763,32 @@ describe("jQuery matchers", function () { expect($('#sandbox').get(0)).not.toHaveData(wrongKey, value) }) }) + + describe("when the value is a JSON object", function() { + var objectKey = 'object-key' + var objectValue = {'foo': 'bar'} + var objectString = '[object Object]' + + beforeEach(function() { + setFixtures(sandbox().data(objectKey, objectValue)) + }) + + it("should pass if element has matching key with matching value", function () { + expect($('#sandbox')).toHaveData(objectKey, objectValue) + expect($('#sandbox').get(0)).toHaveData(objectKey, objectValue) + }) + + it("should not pass if element has matching key but the value is just a string representation of the value", function () { + expect($('#sandbox')).not.toHaveData(objectKey, objectString) + expect($('#sandbox').get(0)).not.toHaveData(objectKey, objectString) + }) + + it("should not pass if element has matching key but the value is just a string representation of the value", function () { + setFixtures('
        ') + expect($('#foo')).not.toHaveData('bar', { 'answer': 42 }) + expect($('#foo').get(0)).not.toHaveData('bar', { 'answer': 42 }) + }) + }) }) describe("toBeVisible", function () { From 3f3e8a786f7cf57c57b1188df77e167a928ebf13 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Fri, 15 Nov 2013 18:25:02 -0500 Subject: [PATCH 50/77] v1.5.93 --- HISTORY.md | 3 +++ bower.json | 2 +- lib/jasmine-jquery.js | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 65ba053e..2caf32e3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,9 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. +## v1.5.93 (Nov 15, 2013) + - fix: check strict equality in `hasProperty` + ## v1.5.92 (Oct 22, 2013) - fix: cloning radio buttons maintains their checked value diff --git a/bower.json b/bower.json index 0585dc80..8e9930f7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.92", + "version": "1.5.93", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index a4305748..fde66438 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 1.5.92 +Version 1.5.93 /~https://github.com/velesin/jasmine-jquery diff --git a/package.json b/package.json index 8e740b7c..6eead123 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.5.92" + , "version": "1.5.93" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { From 5d07ac61f8e1e1836eada74b817129f010b01826 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 22 Dec 2013 20:55:15 -0500 Subject: [PATCH 51/77] use $ rather than jQuery fixes #159 --- lib/jasmine-jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index fde66438..36685f49 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -616,7 +616,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } }) jasmine.getEnv().addEqualityTester(function (a, b) { - if(a instanceof jQuery && b instanceof jQuery) { + if(a instanceof $ && b instanceof $) { if(a.size() != b.size()) { return jasmine.undefined } From b656bc231f506ccfd9634b26d569e76fc14313b3 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 22 Dec 2013 20:55:41 -0500 Subject: [PATCH 52/77] Fix namespace from jasmine.JQuery to jasmine.jQuery --- lib/jasmine-jquery.js | 456 ++++++++++++++--------------- spec/suites/jasmine-jquery-spec.js | 16 +- 2 files changed, 236 insertions(+), 236 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 36685f49..c29aa5e8 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -245,275 +245,271 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. return this[methodName].apply(this, passedArguments) } - jasmine.JQuery = function () {} + jasmine.jQuery = function () {} - jasmine.JQuery.browserTagCaseIndependentHtml = function (html) { + jasmine.jQuery.browserTagCaseIndependentHtml = function (html) { return $('
        ').append(html).html() } - jasmine.JQuery.elementToString = function (element) { + jasmine.jQuery.elementToString = function (element) { return $(element).map(function () { return this.outerHTML; }).toArray().join(', ') } - jasmine.JQuery.matchersClass = {} + jasmine.jQuery.matchersClass = {} - !function (namespace) { - var data = { - spiedEvents: {} - , handlers: [] - } + var data = { + spiedEvents: {} + , handlers: [] + } - namespace.events = { - spyOn: function (selector, eventName) { - var handler = function (e) { - data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) - } + jasmine.jQuery.events = { + spyOn: function (selector, eventName) { + var handler = function (e) { + data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) + } - $(selector).on(eventName, handler) - data.handlers.push(handler) + $(selector).on(eventName, handler) + data.handlers.push(handler) - return { - selector: selector, - eventName: eventName, - handler: handler, - reset: function (){ - delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - } + return { + selector: selector, + eventName: eventName, + handler: handler, + reset: function (){ + delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] } - }, + } + }, - args: function (selector, eventName) { - var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + args: function (selector, eventName) { + var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - if (!actualArgs) { - throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." - } + if (!actualArgs) { + throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." + } - return actualArgs - }, + return actualArgs + }, - wasTriggered: function (selector, eventName) { - return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) - }, + wasTriggered: function (selector, eventName) { + return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) + }, - wasTriggeredWith: function (selector, eventName, expectedArgs, env) { - var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1) - if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { - actualArgs = actualArgs[0] - } - return env.equals_(expectedArgs, actualArgs) - }, + wasTriggeredWith: function (selector, eventName, expectedArgs, env) { + var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1) + if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { + actualArgs = actualArgs[0] + } + return env.equals_(expectedArgs, actualArgs) + }, - wasPrevented: function (selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - , e = args ? args[0] : undefined + wasPrevented: function (selector, eventName) { + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + , e = args ? args[0] : undefined - return e && e.isDefaultPrevented() - }, + return e && e.isDefaultPrevented() + }, - wasStopped: function (selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - , e = args ? args[0] : undefined - return e && e.isPropagationStopped() - }, + wasStopped: function (selector, eventName) { + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + , e = args ? args[0] : undefined + return e && e.isPropagationStopped() + }, - cleanUp: function () { - data.spiedEvents = {} - data.handlers = [] - } + cleanUp: function () { + data.spiedEvents = {} + data.handlers = [] } - }(jasmine.JQuery) + } - !function (){ - var jQueryMatchers = { - toHaveClass: function (className) { - return this.actual.hasClass(className) - }, + var jQueryMatchers = { + toHaveClass: function (className) { + return this.actual.hasClass(className) + }, - toHaveCss: function (css){ - for (var prop in css){ - var value = css[prop] - // see issue #147 on gh - ;if (value === 'auto' && this.actual.get(0).style[prop] === 'auto') continue - if (this.actual.css(prop) !== value) return false - } - return true - }, + toHaveCss: function (css){ + for (var prop in css){ + var value = css[prop] + // see issue #147 on gh + ;if (value === 'auto' && this.actual.get(0).style[prop] === 'auto') continue + if (this.actual.css(prop) !== value) return false + } + return true + }, - toBeVisible: function () { - return this.actual.is(':visible') - }, + toBeVisible: function () { + return this.actual.is(':visible') + }, - toBeHidden: function () { - return this.actual.is(':hidden') - }, + toBeHidden: function () { + return this.actual.is(':hidden') + }, - toBeSelected: function () { - return this.actual.is(':selected') - }, + toBeSelected: function () { + return this.actual.is(':selected') + }, - toBeChecked: function () { - return this.actual.is(':checked') - }, + toBeChecked: function () { + return this.actual.is(':checked') + }, - toBeEmpty: function () { - return this.actual.is(':empty') - }, + toBeEmpty: function () { + return this.actual.is(':empty') + }, - toExist: function () { - return this.actual.length - }, + toExist: function () { + return this.actual.length + }, - toHaveLength: function (length) { - return this.actual.length === length - }, + toHaveLength: function (length) { + return this.actual.length === length + }, - toHaveAttr: function (attributeName, expectedAttributeValue) { - return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) - }, + toHaveAttr: function (attributeName, expectedAttributeValue) { + return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) + }, - toHaveProp: function (propertyName, expectedPropertyValue) { - return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) - }, + toHaveProp: function (propertyName, expectedPropertyValue) { + return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) + }, - toHaveId: function (id) { - return this.actual.attr('id') == id - }, + toHaveId: function (id) { + return this.actual.attr('id') == id + }, - toHaveHtml: function (html) { - return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html) - }, + toHaveHtml: function (html) { + return this.actual.html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) + }, - toContainHtml: function (html){ - var actualHtml = this.actual.html() - , expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) + toContainHtml: function (html){ + var actualHtml = this.actual.html() + , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html) - return (actualHtml.indexOf(expectedHtml) >= 0) - }, + return (actualHtml.indexOf(expectedHtml) >= 0) + }, - toHaveText: function (text) { - var trimmedText = $.trim(this.actual.text()) + toHaveText: function (text) { + var trimmedText = $.trim(this.actual.text()) - if (text && $.isFunction(text.test)) { - return text.test(trimmedText) - } else { - return trimmedText == text - } - }, + if (text && $.isFunction(text.test)) { + return text.test(trimmedText) + } else { + return trimmedText == text + } + }, - toContainText: function (text) { - var trimmedText = $.trim(this.actual.text()) + toContainText: function (text) { + var trimmedText = $.trim(this.actual.text()) - if (text && $.isFunction(text.test)) { - return text.test(trimmedText) - } else { - return trimmedText.indexOf(text) != -1 - } - }, + if (text && $.isFunction(text.test)) { + return text.test(trimmedText) + } else { + return trimmedText.indexOf(text) != -1 + } + }, - toHaveValue: function (value) { - return this.actual.val() === value - }, + toHaveValue: function (value) { + return this.actual.val() === value + }, - toHaveData: function (key, expectedValue) { - return hasProperty(this.actual.data(key), expectedValue) - }, + toHaveData: function (key, expectedValue) { + return hasProperty(this.actual.data(key), expectedValue) + }, - toBe: function (selector) { - return this.actual.is(selector) - }, + toBe: function (selector) { + return this.actual.is(selector) + }, - toContain: function (selector) { - return this.actual.find(selector).length - }, + toContain: function (selector) { + return this.actual.find(selector).length + }, - toBeMatchedBy: function (selector) { - return this.actual.filter(selector).length - }, + toBeMatchedBy: function (selector) { + return this.actual.filter(selector).length + }, - toBeDisabled: function (selector){ - return this.actual.is(':disabled') - }, + toBeDisabled: function (selector){ + return this.actual.is(':disabled') + }, - toBeFocused: function (selector) { - return this.actual[0] === this.actual[0].ownerDocument.activeElement - }, + toBeFocused: function (selector) { + return this.actual[0] === this.actual[0].ownerDocument.activeElement + }, - toHandle: function (event) { - var events = $._data(this.actual.get(0), "events") + toHandle: function (event) { + var events = $._data(this.actual.get(0), "events") - if(!events || !event || typeof event !== "string") { - return false - } + if(!events || !event || typeof event !== "string") { + return false + } - var namespaces = event.split(".") - , eventType = namespaces.shift() - , sortedNamespaces = namespaces.slice(0).sort() - , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") + var namespaces = event.split(".") + , eventType = namespaces.shift() + , sortedNamespaces = namespaces.slice(0).sort() + , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") - if(events[eventType] && namespaces.length) { - for(var i = 0; i < events[eventType].length; i++) { - var namespace = events[eventType][i].namespace + if(events[eventType] && namespaces.length) { + for(var i = 0; i < events[eventType].length; i++) { + var namespace = events[eventType][i].namespace - if(namespaceRegExp.test(namespace)) { - return true - } + if(namespaceRegExp.test(namespace)) { + return true } - } else { - return events[eventType] && events[eventType].length > 0 } - }, - - toHandleWith: function (eventName, eventHandler) { - var normalizedEventName = eventName.split('.')[0] - , stack = $._data(this.actual.get(0), "events")[normalizedEventName] + } else { + return events[eventType] && events[eventType].length > 0 + } + }, - for (var i = 0; i < stack.length; i++) { - if (stack[i].handler == eventHandler) return true - } + toHandleWith: function (eventName, eventHandler) { + var normalizedEventName = eventName.split('.')[0] + , stack = $._data(this.actual.get(0), "events")[normalizedEventName] - return false + for (var i = 0; i < stack.length; i++) { + if (stack[i].handler == eventHandler) return true } + + return false } + } - var hasProperty = function (actualValue, expectedValue) { - if (expectedValue === undefined) return actualValue !== undefined + var hasProperty = function (actualValue, expectedValue) { + if (expectedValue === undefined) return actualValue !== undefined - return actualValue === expectedValue - } + return actualValue === expectedValue + } - var bindMatcher = function (methodName) { - var builtInMatcher = jasmine.Matchers.prototype[methodName] + var bindMatcher = function (methodName) { + var builtInMatcher = jasmine.Matchers.prototype[methodName] - jasmine.JQuery.matchersClass[methodName] = function () { - if (this.actual - && (this.actual instanceof $ - || jasmine.isDomNode(this.actual))) { - this.actual = $(this.actual) - var result = jQueryMatchers[methodName].apply(this, arguments) - , element + jasmine.jQuery.matchersClass[methodName] = function () { + if (this.actual + && (this.actual instanceof $ + || jasmine.isDomNode(this.actual))) { + this.actual = $(this.actual) + var result = jQueryMatchers[methodName].apply(this, arguments) + , element - if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") - this.actual = jasmine.JQuery.elementToString(this.actual) + if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") + this.actual = jasmine.jQuery.elementToString(this.actual) - return result - } + return result + } - if (builtInMatcher) { - return builtInMatcher.apply(this, arguments) - } + if (builtInMatcher) { + return builtInMatcher.apply(this, arguments) + } - return false - } + return false } + } - for(var methodName in jQueryMatchers) { - bindMatcher(methodName) - } - }() + for(var methodName in jQueryMatchers) { + bindMatcher(methodName) + } beforeEach(function () { - this.addMatchers(jasmine.JQuery.matchersClass) + this.addMatchers(jasmine.jQuery.matchersClass) this.addMatchers({ toHaveBeenTriggeredOn: function (selector) { this.message = function () { @@ -522,9 +518,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "Expected event " + this.actual + " not to have been triggered on " + selector ] } - return jasmine.JQuery.events.wasTriggered(selector, this.actual) + return jasmine.jQuery.events.wasTriggered(selector, this.actual) } }) + this.addMatchers({ toHaveBeenTriggered: function (){ var eventName = this.actual.eventName @@ -537,18 +534,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ] } - return jasmine.JQuery.events.wasTriggered(selector, eventName) + return jasmine.jQuery.events.wasTriggered(selector, eventName) } }) + this.addMatchers({ toHaveBeenTriggeredOnAndWith: function () { var selector = arguments[0] , expectedArgs = arguments[1] - , wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) + , wasTriggered = jasmine.jQuery.events.wasTriggered(selector, this.actual) this.message = function () { if (wasTriggered) { - var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] + var actualArgs = jasmine.jQuery.events.args(selector, this.actual, expectedArgs)[1] return [ "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) @@ -561,9 +559,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } } - return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) + return wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) } }) + this.addMatchers({ toHaveBeenPreventedOn: function (selector) { this.message = function () { @@ -573,9 +572,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ] } - return jasmine.JQuery.events.wasPrevented(selector, this.actual) + return jasmine.jQuery.events.wasPrevented(selector, this.actual) } }) + this.addMatchers({ toHaveBeenPrevented: function () { var eventName = this.actual.eventName @@ -587,9 +587,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ] } - return jasmine.JQuery.events.wasPrevented(selector, eventName) + return jasmine.jQuery.events.wasPrevented(selector, eventName) } }) + this.addMatchers({ toHaveBeenStoppedOn: function (selector) { this.message = function () { @@ -599,9 +600,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ] } - return jasmine.JQuery.events.wasStopped(selector, this.actual) + return jasmine.jQuery.events.wasStopped(selector, this.actual) } }) + this.addMatchers({ toHaveBeenStopped: function () { var eventName = this.actual.eventName @@ -612,9 +614,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "Expected event " + eventName + " not to have been stopped on " + selector ] } - return jasmine.JQuery.events.wasStopped(selector, eventName) + return jasmine.jQuery.events.wasStopped(selector, eventName) } }) + jasmine.getEnv().addEqualityTester(function (a, b) { if(a instanceof $ && b instanceof $) { if(a.size() != b.size()) { @@ -632,69 +635,66 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. afterEach(function () { jasmine.getFixtures().cleanUp() jasmine.getStyleFixtures().cleanUp() - jasmine.JQuery.events.cleanUp() + jasmine.jQuery.events.cleanUp() }) -}(window.jasmine, window.jQuery) - -+function (jasmine, global) { "use strict"; - global.readFixtures = function () { + window.readFixtures = function () { return jasmine.getFixtures().proxyCallTo_('read', arguments) } - global.preloadFixtures = function () { + window.preloadFixtures = function () { jasmine.getFixtures().proxyCallTo_('preload', arguments) } - global.loadFixtures = function () { + window.loadFixtures = function () { jasmine.getFixtures().proxyCallTo_('load', arguments) } - global.appendLoadFixtures = function () { + window.appendLoadFixtures = function () { jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) } - global.setFixtures = function (html) { + window.setFixtures = function (html) { return jasmine.getFixtures().proxyCallTo_('set', arguments) } - global.appendSetFixtures = function () { + window.appendSetFixtures = function () { jasmine.getFixtures().proxyCallTo_('appendSet', arguments) } - global.sandbox = function (attributes) { + window.sandbox = function (attributes) { return jasmine.getFixtures().sandbox(attributes) } - global.spyOnEvent = function (selector, eventName) { - return jasmine.JQuery.events.spyOn(selector, eventName) + window.spyOnEvent = function (selector, eventName) { + return jasmine.jQuery.events.spyOn(selector, eventName) } - global.preloadStyleFixtures = function () { + window.preloadStyleFixtures = function () { jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) } - global.loadStyleFixtures = function () { + window.loadStyleFixtures = function () { jasmine.getStyleFixtures().proxyCallTo_('load', arguments) } - global.appendLoadStyleFixtures = function () { + window.appendLoadStyleFixtures = function () { jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) } - global.setStyleFixtures = function (html) { + window.setStyleFixtures = function (html) { jasmine.getStyleFixtures().proxyCallTo_('set', arguments) } - global.appendSetStyleFixtures = function (html) { + window.appendSetStyleFixtures = function (html) { jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) } - global.loadJSONFixtures = function () { + window.loadJSONFixtures = function () { return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) } - global.getJSONFixture = function (url) { + window.getJSONFixture = function (url) { return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] } -}(jasmine, window); +}(window.jasmine, window.jQuery); \ No newline at end of file diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index a02d1270..666c0c7d 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -221,12 +221,12 @@ describe("jasmine.Fixtures", function () { it("should insert HTML into container", function () { jasmine.getFixtures().set(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) it("should insert jQuery element into container", function () { jasmine.getFixtures().set($(html)) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) describe("when fixture container does not exist", function () { @@ -249,7 +249,7 @@ describe("jasmine.Fixtures", function () { it("should replace it with new content", function () { jasmine.getFixtures().set(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) it("should return the fixture container", function (){ @@ -265,7 +265,7 @@ describe("jasmine.Fixtures", function () { it("should be a shortcut global method", function () { setFixtures(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) it("should return the fixture container", function () { @@ -279,17 +279,17 @@ describe("jasmine.Fixtures", function () { var html = '
        some HTML
        ' it("should insert HTML into container", function () { jasmine.getFixtures().appendSet(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) it("should insert jQuery element into container", function () { jasmine.getFixtures().appendSet($(html)) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) it("should have shortcut global method setFixtures", function () { appendSetFixtures(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) describe("when fixture container does not exist", function () { @@ -306,7 +306,7 @@ describe("jasmine.Fixtures", function () { it("should add new content", function () { jasmine.getFixtures().appendSet(html) - expect(fixturesContainer().html()).toEqual(jasmine.JQuery.browserTagCaseIndependentHtml(html)+jasmine.JQuery.browserTagCaseIndependentHtml(html)) + expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)+jasmine.jQuery.browserTagCaseIndependentHtml(html)) }) }) }) From 9e8fae87d8aad7c42e2699b66722733c4cbb5fc0 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 22 Dec 2013 20:56:44 -0500 Subject: [PATCH 53/77] 1.6.0 --- HISTORY.md | 4 ++++ bower.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 2caf32e3..a57155ce 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,10 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. +## v.1.60 (Dec 22, 2013) + - fix: usages of jQuery to use $ (#159) + - change namespace to be jasmine.jQuery + ## v1.5.93 (Nov 15, 2013) - fix: check strict equality in `hasProperty` diff --git a/bower.json b/bower.json index 8e9930f7..9f3edb01 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.5.93", + "version": "1.6.0", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/package.json b/package.json index 6eead123..2eb90259 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.5.93" + , "version": "1.6.0" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { From 9f18726df1d5d8de9fa5f1145e7702af08e57649 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sun, 22 Dec 2013 21:01:03 -0500 Subject: [PATCH 54/77] fixes #158 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eec9f682..0c66a3b1 100644 --- a/README.md +++ b/README.md @@ -80,9 +80,9 @@ jasmine-jquery provides following custom matchers (in alphabetical order): - `toHaveLength(value)` - e.g. `expect($('ul > li')).toHaveLength(3)` - `toBeDisabled()` - - e.g. `expect('').toBeDisabled()` + - e.g. `expect('').toBeDisabled()` - `toBeFocused()` - - e.g. `expect($('').focus()).toBeFocused()` + - e.g. `expect($('').focus()).toBeFocused()` - `toHandle(eventName)` - e.g. `expect($form).toHandle("submit")` - `toHandleWith(eventName, eventHandler)` From 567fc733a771d7d942d8fc85d7edc63472df5d06 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Thu, 26 Dec 2013 17:41:38 -0500 Subject: [PATCH 55/77] fix #160 --- lib/jasmine-jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index c29aa5e8..ca9c4bf8 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 1.5.93 +Version 1.6.0 /~https://github.com/velesin/jasmine-jquery From c20dac7221db366837b7fe340b00904c64d202ea Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 27 Dec 2013 16:58:22 -0800 Subject: [PATCH 56/77] Adding toBeInDOM and tests --- lib/jasmine-jquery.js | 7 ++++++- spec/suites/jasmine-jquery-spec.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index ca9c4bf8..de425507 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -357,6 +357,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. return this.actual.is(':empty') }, + toBeInDOM: function () { + return this.actual.closest(document.body).length + }, + toExist: function () { return this.actual.length }, @@ -697,4 +701,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. window.getJSONFixture = function (url) { return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] } -}(window.jasmine, window.jQuery); \ No newline at end of file +}(window.jasmine, window.jQuery); + diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 666c0c7d..e07f6522 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -883,6 +883,17 @@ describe("jQuery matchers", function () { }) }) + describe("toBeInDOM", function () { + it("should pass on elements in the DOM", function () { + setFixtures(sandbox()) + expect($('#sandbox')).toBeInDOM() + }) + + it("should pass negated on elements not in the DOM", function () { + expect($('
        ')).not.toBeInDOM() + }) + }) + describe("toExist", function () { it("should pass on visible element", function () { setFixtures(sandbox()) From e18da7d134b85ee0e20421a955e33c6043aa2abd Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Fri, 27 Dec 2013 23:54:55 -0500 Subject: [PATCH 57/77] Improve performance of `toBeInDOM()` (#161) See: http://jsperf.com/jquery-element-in-dom/2 --- lib/jasmine-jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index de425507..6cb5ef41 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -358,7 +358,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }, toBeInDOM: function () { - return this.actual.closest(document.body).length + return $.contains(document.documentElement, this.actual[0]) }, toExist: function () { From 95120d9aac9074d1b6f9c2c043f67e64e99e3e35 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 28 Dec 2013 00:00:44 -0500 Subject: [PATCH 58/77] 1.7.0 --- HISTORY.md | 5 ++++- bower.json | 2 +- lib/jasmine-jquery.js | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index a57155ce..b85bd3ad 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,10 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. -## v.1.60 (Dec 22, 2013) +## v.1.7.0 (Dec 27, 2013) + - add: toBeInDOM() matcher + +## v1.60 (Dec 22, 2013) - fix: usages of jQuery to use $ (#159) - change namespace to be jasmine.jQuery diff --git a/bower.json b/bower.json index 9f3edb01..bc2ad1f3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "1.6.0", + "version": "1.7.0", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 6cb5ef41..a0f28606 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 1.6.0 +Version 1.7.0 /~https://github.com/velesin/jasmine-jquery diff --git a/package.json b/package.json index 2eb90259..f1dba977 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.6.0" + , "version": "1.7.0" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { From d94786ebffaf36ff7f43579a8afd55fde91b3e4d Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Mon, 30 Dec 2013 16:26:07 -0500 Subject: [PATCH 59/77] Pass in window to the self invoking function --- lib/jasmine-jquery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index a0f28606..2e638871 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -27,7 +27,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -+function (jasmine, $) { "use strict"; ++function (window, jasmine, $) { "use strict"; jasmine.spiedEventsKey = function (selector, eventName) { return [$(selector).selector, eventName].toString() @@ -701,5 +701,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. window.getJSONFixture = function (url) { return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] } -}(window.jasmine, window.jQuery); +}(window, window.jasmine, window.jQuery); From b7296ff3d358f52dcc763de836fd78e2be8bde6d Mon Sep 17 00:00:00 2001 From: Jichao Ouyang Date: Wed, 1 Jan 2014 22:04:46 -0500 Subject: [PATCH 60/77] Able to bind events to fixtures --- lib/jasmine-jquery.js | 18 ++++++++++++- spec/fixtures/fixture_with_javascript.html | 1 + .../javascripts/jasmine_javascript_click.js | 1 + .../javascripts/jasmine_javascript_hover.js | 1 + spec/suites/jasmine-jquery-spec.js | 26 +++++++++++++++++-- 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/fixture_with_javascript.html create mode 100644 spec/fixtures/javascripts/jasmine_javascript_click.js create mode 100644 spec/fixtures/javascripts/jasmine_javascript_hover.js diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 2e638871..67ee3885 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -119,17 +119,33 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { var self = this , url = this.makeFixtureUrl_(relativeUrl) + , htmlText = '' , request = $.ajax({ async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded cache: false, url: url, success: function (data, status, $xhr) { - self.fixturesCache_[relativeUrl] = $xhr.responseText + htmlText = $xhr.responseText }, error: function (jqXHR, status, errorThrown) { throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') } }) + var scripts = $($.parseHTML(htmlText, true)).find('script') || []; + scripts.each(function(){ + $.ajax({ + async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded + cache: false, + url: $(this).attr('src'), + success: function (data, status, $xhr) { + htmlText += '' + }, + error: function (jqXHR, status, errorThrown) { + throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + } + }); + }) + self.fixturesCache_[relativeUrl] = htmlText; } jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){ diff --git a/spec/fixtures/fixture_with_javascript.html b/spec/fixtures/fixture_with_javascript.html new file mode 100644 index 00000000..cdc34df6 --- /dev/null +++ b/spec/fixtures/fixture_with_javascript.html @@ -0,0 +1 @@ +
        diff --git a/spec/fixtures/javascripts/jasmine_javascript_click.js b/spec/fixtures/javascripts/jasmine_javascript_click.js new file mode 100644 index 00000000..707cc8da --- /dev/null +++ b/spec/fixtures/javascripts/jasmine_javascript_click.js @@ -0,0 +1 @@ +$(function (){ $('#anchor_01').click(function(){ $(this).addClass('foo'); }) }); \ No newline at end of file diff --git a/spec/fixtures/javascripts/jasmine_javascript_hover.js b/spec/fixtures/javascripts/jasmine_javascript_hover.js new file mode 100644 index 00000000..48121a03 --- /dev/null +++ b/spec/fixtures/javascripts/jasmine_javascript_hover.js @@ -0,0 +1 @@ +$(function (){ $('#anchor_01').on('hover', function(){ $(this).addClass('bar'); }) }); diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index e07f6522..1b90c35a 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -128,7 +128,6 @@ describe("jasmine.Fixtures", function () { expect($("#anchor_01")).toHaveClass('foo') }) }) - }) describe("appendLoad", function () { @@ -399,6 +398,30 @@ describe("jasmine.Fixtures using real AJAX call", function () { }).toThrow() }) }) + + describe("when fixture contains an ' @@ -145,6 +149,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } }); }) + self.fixturesCache_[relativeUrl] = htmlText; } @@ -271,8 +276,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. return $(element).map(function () { return this.outerHTML; }).toArray().join(', ') } - jasmine.jQuery.matchersClass = {} - var data = { spiedEvents: {} , handlers: [] @@ -311,12 +314,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) }, - wasTriggeredWith: function (selector, eventName, expectedArgs, env) { + wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) { var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1) - if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { + + if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') actualArgs = actualArgs[0] - } - return env.equals_(expectedArgs, actualArgs) + + return util.equals(expectedArgs, actualArgs, customEqualityTesters) }, wasPrevented: function (selector, eventName) { @@ -338,317 +342,406 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } } - var jQueryMatchers = { - toHaveClass: function (className) { - return this.actual.hasClass(className) - }, + var hasProperty = function (actualValue, expectedValue) { + if (expectedValue === undefined) + return actualValue !== undefined - toHaveCss: function (css){ - for (var prop in css){ - var value = css[prop] - // see issue #147 on gh - ;if (value === 'auto' && this.actual.get(0).style[prop] === 'auto') continue - if (this.actual.css(prop) !== value) return false - } - return true - }, + return actualValue === expectedValue + } - toBeVisible: function () { - return this.actual.is(':visible') - }, + beforeEach(function () { + jasmine.addMatchers({ + toHaveClass: function () { + return { + compare: function (actual, className) { + return { pass: $(actual).hasClass(className) } + } + } + }, - toBeHidden: function () { - return this.actual.is(':hidden') - }, + toHaveCss: function () { + return { + compare: function (actual, css) { + for (var prop in css){ + var value = css[prop] + // see issue #147 on gh + ;if (value === 'auto' && $(actual).get(0).style[prop] === 'auto') continue + if ($(actual).css(prop) !== value) return { pass: false } + } + return { pass: true } + } + } + }, - toBeSelected: function () { - return this.actual.is(':selected') - }, + toBeVisible: function () { + return { + compare: function (actual) { + return { pass: $(actual).is(':visible') } + } + } + }, - toBeChecked: function () { - return this.actual.is(':checked') - }, + toBeHidden: function () { + return { + compare: function (actual) { + return { pass: $(actual).is(':hidden') } + } + } + }, - toBeEmpty: function () { - return this.actual.is(':empty') - }, + toBeSelected: function () { + return { + compare: function (actual) { + return { pass: $(actual).is(':selected') } + } + } + }, - toBeInDOM: function () { - return $.contains(document.documentElement, this.actual[0]) - }, + toBeChecked: function () { + return { + compare: function (actual) { + return { pass: $(actual).is(':checked') } + } + } + }, - toExist: function () { - return this.actual.length - }, + toBeEmpty: function () { + return { + compare: function (actual) { + return { pass: $(actual).is(':empty') } + } + } + }, - toHaveLength: function (length) { - return this.actual.length === length - }, + toBeInDOM: function () { + return { + compare: function (actual) { + return { pass: $.contains(document.documentElement, $(actual)[0]) } + } + } + }, - toHaveAttr: function (attributeName, expectedAttributeValue) { - return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) - }, + toExist: function () { + return { + compare: function (actual) { + return { pass: $(actual).length } + } + } + }, - toHaveProp: function (propertyName, expectedPropertyValue) { - return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) - }, + toHaveLength: function () { + return { + compare: function (actual, length) { + return { pass: $(actual).length === length } + } + } + }, - toHaveId: function (id) { - return this.actual.attr('id') == id - }, + toHaveAttr: function () { + return { + compare: function (actual, attributeName, expectedAttributeValue) { + return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) } + } + } + }, - toHaveHtml: function (html) { - return this.actual.html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) - }, + toHaveProp: function () { + return { + compare: function (actual, propertyName, expectedPropertyValue) { + return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) } + } + } + }, - toContainHtml: function (html){ - var actualHtml = this.actual.html() - , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html) + toHaveId: function () { + return { + compare: function (actual, id) { + return { pass: $(actual).attr('id') == id } + } + } + }, - return (actualHtml.indexOf(expectedHtml) >= 0) - }, + toHaveHtml: function () { + return { + compare: function (actual, html) { + return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) } + } + } + }, - toHaveText: function (text) { - var trimmedText = $.trim(this.actual.text()) + toContainHtml: function () { + return { + compare: function (actual, html) { + var actualHtml = $(actual).html() + , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html) - if (text && $.isFunction(text.test)) { - return text.test(trimmedText) - } else { - return trimmedText == text - } - }, + return { pass: (actualHtml.indexOf(expectedHtml) >= 0) } + } + } + }, - toContainText: function (text) { - var trimmedText = $.trim(this.actual.text()) + toHaveText: function () { + return { + compare: function (actual, text) { + var trimmedText = $.trim($(actual).text()) - if (text && $.isFunction(text.test)) { - return text.test(trimmedText) - } else { - return trimmedText.indexOf(text) != -1 - } - }, + if (text && $.isFunction(text.test)) { + return { pass: text.test(trimmedText) } + } else { + return { pass: trimmedText == text } + } + } + } + }, - toHaveValue: function (value) { - return this.actual.val() === value - }, + toContainText: function () { + return { + compare: function (actual, text) { + var trimmedText = $.trim($(actual).text()) - toHaveData: function (key, expectedValue) { - return hasProperty(this.actual.data(key), expectedValue) - }, + if (text && $.isFunction(text.test)) { + return { pass: text.test(trimmedText) } + } else { + return { pass: trimmedText.indexOf(text) != -1 } + } + } + } + }, - toBe: function (selector) { - return this.actual.is(selector) - }, + toHaveValue: function () { + return { + compare: function (actual, value) { + return { pass: $(actual).val() === value } + } + } + }, - toContain: function (selector) { - return this.actual.find(selector).length - }, + toHaveData: function () { + return { + compare: function (actual, key, expectedValue) { + return { pass: hasProperty($(actual).data(key), expectedValue) } + } + } + }, - toBeMatchedBy: function (selector) { - return this.actual.filter(selector).length - }, + toContainElement: function () { + return { + compare: function (actual, selector) { + if (window.debug) debugger + return { pass: $(actual).find(selector).length } + } + } + }, - toBeDisabled: function (selector){ - return this.actual.is(':disabled') - }, + toBeMatchedBy: function () { + return { + compare: function (actual, selector) { + return { pass: $(actual).filter(selector).length } + } + } + }, - toBeFocused: function (selector) { - return this.actual[0] === this.actual[0].ownerDocument.activeElement - }, + toBeDisabled: function () { + return { + compare: function (actual, selector) { + return { pass: $(actual).is(':disabled') } + } + } + }, + + toBeFocused: function (selector) { + return { + compare: function (actual, selector) { + return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement } + } + } + }, - toHandle: function (event) { - var events = $._data(this.actual.get(0), "events") + toHandle: function () { + return { + compare: function (actual, event) { + var events = $._data($(actual).get(0), "events") - if(!events || !event || typeof event !== "string") { - return false - } + if (!events || !event || typeof event !== "string") { + return { pass: false } + } - var namespaces = event.split(".") - , eventType = namespaces.shift() - , sortedNamespaces = namespaces.slice(0).sort() - , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") + var namespaces = event.split(".") + , eventType = namespaces.shift() + , sortedNamespaces = namespaces.slice(0).sort() + , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") - if(events[eventType] && namespaces.length) { - for(var i = 0; i < events[eventType].length; i++) { - var namespace = events[eventType][i].namespace + if (events[eventType] && namespaces.length) { + for (var i = 0; i < events[eventType].length; i++) { + var namespace = events[eventType][i].namespace - if(namespaceRegExp.test(namespace)) { - return true + if (namespaceRegExp.test(namespace)) + return { pass: true } + } + } else { + return { pass: (events[eventType] && events[eventType].length > 0) } + } + + return { pass: false } } } - } else { - return events[eventType] && events[eventType].length > 0 - } - }, + }, - toHandleWith: function (eventName, eventHandler) { - var normalizedEventName = eventName.split('.')[0] - , stack = $._data(this.actual.get(0), "events")[normalizedEventName] + toHandleWith: function () { + return { + compare: function (actual, eventName, eventHandler) { + var normalizedEventName = eventName.split('.')[0] + , stack = $._data($(actual).get(0), "events")[normalizedEventName] - for (var i = 0; i < stack.length; i++) { - if (stack[i].handler == eventHandler) return true - } + for (var i = 0; i < stack.length; i++) { + if (stack[i].handler == eventHandler) return { pass: true } + } - return false - } - } + return { pass: false } + } + } + }, - var hasProperty = function (actualValue, expectedValue) { - if (expectedValue === undefined) return actualValue !== undefined + toHaveBeenTriggeredOn: function () { + return { + compare: function (actual, selector) { + var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) } - return actualValue === expectedValue - } + result.message = result.pass ? + "Expected event " + $(actual) + " not to have been triggered on " + selector : + "Expected event " + $(actual) + " to have been triggered on " + selector - var bindMatcher = function (methodName) { - var builtInMatcher = jasmine.Matchers.prototype[methodName] + return result; + } + } + }, - jasmine.jQuery.matchersClass[methodName] = function () { - if (this.actual - && (this.actual instanceof $ - || jasmine.isDomNode(this.actual))) { - this.actual = $(this.actual) - var result = jQueryMatchers[methodName].apply(this, arguments) - , element + toHaveBeenTriggered: function (){ + return { + compare: function (actual) { + var eventName = actual.eventName + , selector = actual.selector + , result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) } - if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") - this.actual = jasmine.jQuery.elementToString(this.actual) + result.message = result.pass ? + "Expected event " + eventName + " not to have been triggered on " + selector : + "Expected event " + eventName + " to have been triggered on " + selector return result } + } + }, - if (builtInMatcher) { - return builtInMatcher.apply(this, arguments) + toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) { + return { + compare: function (actual, selector, expectedArgs) { + var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual) + , result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) } + + if (wasTriggered) { + var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1] + result.message = result.pass ? + "Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) : + "Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) + + } else { + // todo check on this + result.message = result.pass ? + "Expected event " + actual + " not to have been triggered on " + selector : + "Expected event " + actual + " to have been triggered on " + selector + } + + return result } + } + }, - return false - } - } + toHaveBeenPreventedOn: function () { + return { + compare: function (actual, selector) { + var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) } - for(var methodName in jQueryMatchers) { - bindMatcher(methodName) - } + result.message = result.pass ? + "Expected event " + actual + " not to have been prevented on " + selector : + "Expected event " + actual + " to have been prevented on " + selector - beforeEach(function () { - this.addMatchers(jasmine.jQuery.matchersClass) - this.addMatchers({ - toHaveBeenTriggeredOn: function (selector) { - this.message = function () { - return [ - "Expected event " + this.actual + " to have been triggered on " + selector, - "Expected event " + this.actual + " not to have been triggered on " + selector - ] - } - return jasmine.jQuery.events.wasTriggered(selector, this.actual) - } - }) + return result + } + } + }, - this.addMatchers({ - toHaveBeenTriggered: function (){ - var eventName = this.actual.eventName - , selector = this.actual.selector + toHaveBeenPrevented: function () { + return { + compare: function (actual) { + var eventName = actual.eventName + , selector = actual.selector + , result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) } + + result.message = result.pass ? + "Expected event " + eventName + " not to have been prevented on " + selector : + "Expected event " + eventName + " to have been prevented on " + selector - this.message = function () { - return [ - "Expected event " + eventName + " to have been triggered on " + selector, - "Expected event " + eventName + " not to have been triggered on " + selector - ] + return result + } } + }, - return jasmine.jQuery.events.wasTriggered(selector, eventName) - } - }) + toHaveBeenStoppedOn: function () { + return { + compare: function (actual, selector) { + var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) } - this.addMatchers({ - toHaveBeenTriggeredOnAndWith: function () { - var selector = arguments[0] - , expectedArgs = arguments[1] - , wasTriggered = jasmine.jQuery.events.wasTriggered(selector, this.actual) + result.message = result.pass ? + "Expected event " + actual + " not to have been stopped on " + selector : + "Expected event " + actual + " to have been stopped on " + selector - this.message = function () { - if (wasTriggered) { - var actualArgs = jasmine.jQuery.events.args(selector, this.actual, expectedArgs)[1] - return [ - "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), - "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) - ] - } else { - return [ - "Expected event " + this.actual + " to have been triggered on " + selector, - "Expected event " + this.actual + " not to have been triggered on " + selector - ] + return result; } } + }, - return wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) - } - }) + toHaveBeenStopped: function () { + return { + compare: function (actual) { + var eventName = actual.eventName + , selector = actual.selector + , result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) } - this.addMatchers({ - toHaveBeenPreventedOn: function (selector) { - this.message = function () { - return [ - "Expected event " + this.actual + " to have been prevented on " + selector, - "Expected event " + this.actual + " not to have been prevented on " + selector - ] - } + result.message = result.pass ? + "Expected event " + eventName + " not to have been stopped on " + selector : + "Expected event " + eventName + " to have been stopped on " + selector - return jasmine.jQuery.events.wasPrevented(selector, this.actual) + return result + } + } } }) - this.addMatchers({ - toHaveBeenPrevented: function () { - var eventName = this.actual.eventName - , selector = this.actual.selector - this.message = function () { - return [ - "Expected event " + eventName + " to have been prevented on " + selector, - "Expected event " + eventName + " not to have been prevented on " + selector - ] - } + jasmine.getEnv().addCustomEqualityTester(function(a, b) { + if (a && b) { + if (a instanceof $ || jasmine.isDomNode(a)) { + var $a = $(a) - return jasmine.jQuery.events.wasPrevented(selector, eventName) - } - }) + if (b instanceof $) + return $a.length == b.length && a.is(b) - this.addMatchers({ - toHaveBeenStoppedOn: function (selector) { - this.message = function () { - return [ - "Expected event " + this.actual + " to have been stopped on " + selector, - "Expected event " + this.actual + " not to have been stopped on " + selector - ] - } + return $a.is(b); + } - return jasmine.jQuery.events.wasStopped(selector, this.actual) - } - }) + if (b instanceof $ || jasmine.isDomNode(b)) { + var $b = $(b) - this.addMatchers({ - toHaveBeenStopped: function () { - var eventName = this.actual.eventName - , selector = this.actual.selector - this.message = function () { - return [ - "Expected event " + eventName + " to have been stopped on " + selector, - "Expected event " + eventName + " not to have been stopped on " + selector - ] - } - return jasmine.jQuery.events.wasStopped(selector, eventName) - } - }) + if (a instanceof jQuery) + return a.length == $b.length && $b.is(a) - jasmine.getEnv().addEqualityTester(function (a, b) { - if(a instanceof $ && b instanceof $) { - if(a.size() != b.size()) { - return jasmine.undefined - } - else if(a.is(b)) { - return true - } - } + return $(b).is(a); + } + } + }) - return jasmine.undefined + jasmine.getEnv().addCustomEqualityTester(function (a, b) { + if (a instanceof jQuery && b instanceof jQuery && a.size() == b.size()) + return a.is(b) }) }) diff --git a/package.json b/package.json index 945bdee3..13855c4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "1.7.0" + , "version": "2.0.0" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": { @@ -21,6 +21,6 @@ , "devDependencies": { "grunt": "~0.4.1" , "grunt-contrib-jshint": "~0.6.0" - , "grunt-contrib-jasmine": "git://github.com/travisjeffery/grunt-contrib-jasmine#fa720365d48a04befe058666cd683ca2bdee1e6f" + , "grunt-contrib-jasmine": "git://github.com/travisjeffery/grunt-contrib-jasmine#9d5874dd592cf41e8268918fe9baeb261afd75b2" } } diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index 1b90c35a..ad47228e 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -11,7 +11,7 @@ describe("jasmine.Fixtures", function () { beforeEach(function () { jasmine.getFixtures().clearCache() - spyOn(jasmine.Fixtures.prototype, 'loadFixtureIntoCache_').andCallFake(function (relativeUrl){ + spyOn(jasmine.Fixtures.prototype, 'loadFixtureIntoCache_').and.callFake(function (relativeUrl){ this.fixturesCache_[relativeUrl] = ajaxData }) }) @@ -32,18 +32,18 @@ describe("jasmine.Fixtures", function () { jasmine.getFixtures().read(fixtureUrl) jasmine.getFixtures().clearCache() jasmine.getFixtures().read(fixtureUrl) - expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2) + expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2) }) }) it("first-time read should go through AJAX", function () { jasmine.getFixtures().read(fixtureUrl) - expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1) + expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1) }) it("subsequent read from the same URL should go from cache", function () { jasmine.getFixtures().read(fixtureUrl, fixtureUrl) - expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1) + expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1) }) }) @@ -193,7 +193,7 @@ describe("jasmine.Fixtures", function () { it("should go from cache", function () { jasmine.getFixtures().preload(fixtureUrl, anotherFixtureUrl) jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl) - expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2) + expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2) }) it("should return correct HTMLs", function () { @@ -205,13 +205,13 @@ describe("jasmine.Fixtures", function () { it("should not preload the same fixture twice", function () { jasmine.getFixtures().preload(fixtureUrl, fixtureUrl) - expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(1) + expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1) }) it("should have shortcut global method preloadFixtures", function () { preloadFixtures(fixtureUrl, anotherFixtureUrl) jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl) - expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.callCount).toEqual(2) + expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2) }) }) @@ -402,11 +402,6 @@ describe("jasmine.Fixtures using real AJAX call", function () { describe("when fixture contains an
        diff --git a/spec/suites/jasmine-jquery-spec.js b/spec/suites/jasmine-jquery-spec.js index ad47228e..360776a7 100644 --- a/spec/suites/jasmine-jquery-spec.js +++ b/spec/suites/jasmine-jquery-spec.js @@ -416,6 +416,15 @@ describe("jasmine.Fixtures using real AJAX call", function () { expect($("#anchor_01")).toHaveClass('bar') }) }) + + describe("when fixture contains a ' }, - error: function (jqXHR, status, errorThrown) { - throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + error: function ($xhr, status, err) { + throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + err.message + ')') } }); }) @@ -255,8 +255,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. success: function (data) { self.fixturesCache_[relativeUrl] = data }, - error: function (jqXHR, status, errorThrown) { - throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + error: function ($xhr, status, err) { + throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')') } }) } From c5fda66b6841da716ffdaf07d8f01da1d61ce97c Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Tue, 18 Feb 2014 15:32:29 -0500 Subject: [PATCH 76/77] fix #179 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f099cf2..48cbae5d 100644 --- a/README.md +++ b/README.md @@ -341,7 +341,7 @@ jasmine-jquery is tested with jQuery 2.0 on IE, FF, Chrome, and Safari. There is ## Cross domain policy problems under Chrome -Newer versions of Chrome don't allow file:// URIs read other file:// URIs. In effect, jasmine-jquery cannot properly load fixtures under some versions of Chrome. An override for this is to run Chrome with a switch `--allow-file-access-from-files`. The full discussion on this topic can be found in [this GitHub ticket](/~https://github.com/velesin/jasmine-jquery/issues/4). +Newer versions of Chrome don't allow file:// URIs read other file:// URIs. In effect, jasmine-jquery cannot properly load fixtures under some versions of Chrome. An override for this is to run Chrome with a switch `--allow-file-access-from-files`. (/~https://github.com/velesin/jasmine-jquery/issues/4). Quit open Chromes before running Chrome with that switch. (/~https://github.com/velesin/jasmine-jquery/issues/179). Under Windows 7, you have to launch `C:\Users\[UserName]\AppData\Local\Google\Chrome[ SxS]\Application\chrome.exe --allow-file-access-from-files` From b94ad8741909b8a48521d168a1ae6b742180122e Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Tue, 18 Feb 2014 15:35:01 -0500 Subject: [PATCH 77/77] 2.0.3 --- HISTORY.md | 4 ++++ bower.json | 2 +- lib/jasmine-jquery.js | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 00a674ad..4edcfd22 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,10 @@ This is an overview and may be incomplete. /~https://github.com/velesin/jasmine-jquery/commits/master is where to see everything. +## v2.0.3 (2014-02-49) + + - fix: xhr failure requests (#174) + ## v2.0.2 (2014-01-23) - fix: don't load inline js in fixtures (for templates, etc.) diff --git a/bower.json b/bower.json index 1ce88ae7..b08e24b9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-jquery", - "version": "2.0.2", + "version": "2.0.3", "main": "lib/jasmine-jquery.js", "ignore": [ "test", diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js index 72ac0234..d3c3871b 100644 --- a/lib/jasmine-jquery.js +++ b/lib/jasmine-jquery.js @@ -1,7 +1,7 @@ /*! Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. -Version 2.0.2 +Version 2.1.0 /~https://github.com/velesin/jasmine-jquery diff --git a/package.json b/package.json index 12e905ed..64030e48 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-jquery" , "description": "jQuery matchers and fixture loader for Jasmine framework" - , "version": "2.0.2" + , "version": "2.0.3" , "keywords": ["jasmine", "jquery"] , "homepage": "http://github.com/velesin/jasmine-jquery" , "author": {