diff --git a/doc/files.html b/doc/files.html index dd38626..c214ba9 100644 --- a/doc/files.html +++ b/doc/files.html @@ -260,7 +260,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 7413bd4..ef9ba6e 100644 --- a/doc/index.html +++ b/doc/index.html @@ -308,7 +308,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index c11f55b..ced27c2 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -910,7 +910,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:02 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index 74b37ef..dc46048 100644 --- a/doc/symbols/jasmine.Block.html +++ b/doc/symbols/jasmine.Block.html @@ -341,7 +341,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:02 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index f085258..80009df 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -509,7 +509,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index 680bd84..20c5cda 100644 --- a/doc/symbols/jasmine.JsApiReporter.html +++ b/doc/symbols/jasmine.JsApiReporter.html @@ -318,7 +318,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Matchers.html b/doc/symbols/jasmine.Matchers.html index 354af43..a38cc07 100644 --- a/doc/symbols/jasmine.Matchers.html +++ b/doc/symbols/jasmine.Matchers.html @@ -1012,7 +1012,7 @@ a pattern or a String.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index 4583077..119789f 100644 --- a/doc/symbols/jasmine.MultiReporter.html +++ b/doc/symbols/jasmine.MultiReporter.html @@ -318,7 +318,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 297c8ef..493d822 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -702,7 +702,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index 75d611b..1eccc2f 100644 --- a/doc/symbols/jasmine.Reporter.html +++ b/doc/symbols/jasmine.Reporter.html @@ -318,7 +318,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index 33a0020..e8d2bce 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -329,7 +329,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index 50f500d..26d021f 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -341,7 +341,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 55d0e19..5b1285c 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -847,7 +847,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index 29f8593..d6763a6 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -347,7 +347,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 8196f3e..6ace81d 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -730,7 +730,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:02 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 4540ba5..2739c67 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -318,7 +318,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 16:48:57 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Oct 27 2009 21:17:03 GMT-0800 (PST)
diff --git a/doc/symbols/src/lib_TrivialReporter.js.html b/doc/symbols/src/lib_TrivialReporter.js.html index 4f23e2c..fb10163 100644 --- a/doc/symbols/src/lib_TrivialReporter.js.html +++ b/doc/symbols/src/lib_TrivialReporter.js.html @@ -24,121 +24,114 @@ 17 } 18 19 for (var attr in attrs) { - 20 if (attr == 'className') { - 21 el.setAttribute('class', attrs[attr]); - 22 //twice for ie - 23 el.setAttribute('className', attrs[attr]); - 24 } else { - 25 el[attr] = attrs[attr]; - 26 } - 27 } + 20 el[attr] = attrs[attr]; + 21 } + 22 + 23 return el; + 24 }; + 25 + 26 jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { + 27 var suites = runner.suites(); 28 - 29 return el; - 30 }; - 31 - 32 jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { - 33 var suites = runner.suites(); - 34 - 35 this.runnerDiv = this.createDom('div', { className: 'runner running' }, - 36 this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), - 37 this.runnerMessageSpan = this.createDom('span', {}, "Running...")); - 38 this.document.body.appendChild(this.runnerDiv); - 39 - 40 for (var i = 0; i < suites.length; i++) { - 41 var suite = suites[i]; - 42 var suiteDiv = this.createDom('div', { className: 'suite' }, - 43 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), - 44 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); - 45 this.suiteDivs[suite.getFullName()] = suiteDiv; - 46 var parentDiv = this.document.body; - 47 if (suite.parentSuite) { - 48 parentDiv = this.suiteDivs[suite.parentSuite.getFullName()]; - 49 } - 50 parentDiv.appendChild(suiteDiv); - 51 } - 52 - 53 this.startedAt = new Date(); - 54 }; - 55 - 56 jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { - 57 var results = runner.results(); - 58 var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; - 59 this.runnerDiv.setAttribute("class", className); - 60 //do it twice for IE - 61 this.runnerDiv.setAttribute("className", className); - 62 var specs = runner.specs(); - 63 var specCount = 0; - 64 for (var i = 0; i < specs.length; i++) { - 65 if (this.specFilter(specs[i])) { - 66 specCount++; - 67 } - 68 } - 69 var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); - 70 message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; - 71 this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); - 72 }; - 73 - 74 jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { - 75 var results = suite.results(); - 76 var status = results.passed() ? 'passed' : 'failed'; - 77 if (results.totalCount == 0) { // todo: change this to check results.skipped - 78 status = 'skipped'; - 79 } - 80 this.suiteDivs[suite.getFullName()].className += " " + status; - 81 }; - 82 - 83 jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { - 84 var results = spec.results(); - 85 var status = results.passed() ? 'passed' : 'failed'; - 86 if (results.skipped) { - 87 status = 'skipped'; - 88 } - 89 var specDiv = this.createDom('div', { className: 'spec ' + status }, - 90 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), - 91 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, spec.getFullName())); - 92 - 93 - 94 var resultItems = results.getItems(); - 95 for (var i = 0; i < resultItems.length; i++) { - 96 var result = resultItems[i]; - 97 if (result.passed && !result.passed()) { - 98 var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'}); - 99 resultMessageDiv.innerHTML = result.message; // todo: lame; mend -100 specDiv.appendChild(resultMessageDiv); -101 specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); -102 } -103 } + 29 this.runnerDiv = this.createDom('div', { className: 'runner running' }, + 30 this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), + 31 this.runnerMessageSpan = this.createDom('span', {}, "Running...")); + 32 this.document.body.appendChild(this.runnerDiv); + 33 + 34 for (var i = 0; i < suites.length; i++) { + 35 var suite = suites[i]; + 36 var suiteDiv = this.createDom('div', { className: 'suite' }, + 37 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), + 38 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); + 39 this.suiteDivs[suite.getFullName()] = suiteDiv; + 40 var parentDiv = this.document.body; + 41 if (suite.parentSuite) { + 42 parentDiv = this.suiteDivs[suite.parentSuite.getFullName()]; + 43 } + 44 parentDiv.appendChild(suiteDiv); + 45 } + 46 + 47 this.startedAt = new Date(); + 48 }; + 49 + 50 jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { + 51 var results = runner.results(); + 52 var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; + 53 this.runnerDiv.setAttribute("class", className); + 54 //do it twice for IE + 55 this.runnerDiv.setAttribute("className", className); + 56 var specs = runner.specs(); + 57 var specCount = 0; + 58 for (var i = 0; i < specs.length; i++) { + 59 if (this.specFilter(specs[i])) { + 60 specCount++; + 61 } + 62 } + 63 var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); + 64 message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; + 65 this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); + 66 }; + 67 + 68 jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { + 69 var results = suite.results(); + 70 var status = results.passed() ? 'passed' : 'failed'; + 71 if (results.totalCount == 0) { // todo: change this to check results.skipped + 72 status = 'skipped'; + 73 } + 74 this.suiteDivs[suite.getFullName()].className += " " + status; + 75 }; + 76 + 77 jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { + 78 var results = spec.results(); + 79 var status = results.passed() ? 'passed' : 'failed'; + 80 if (results.skipped) { + 81 status = 'skipped'; + 82 } + 83 var specDiv = this.createDom('div', { className: 'spec ' + status }, + 84 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), + 85 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, spec.getFullName())); + 86 + 87 + 88 var resultItems = results.getItems(); + 89 for (var i = 0; i < resultItems.length; i++) { + 90 var result = resultItems[i]; + 91 if (result.passed && !result.passed()) { + 92 var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'}); + 93 resultMessageDiv.innerHTML = result.message; // todo: lame; mend + 94 specDiv.appendChild(resultMessageDiv); + 95 specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); + 96 } + 97 } + 98 this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); + 99 }; +100 +101 jasmine.TrivialReporter.prototype.log = function() { +102 console.log.apply(console, arguments); +103 }; 104 -105 this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); -106 }; -107 -108 jasmine.TrivialReporter.prototype.log = function() { -109 console.log.apply(console, arguments); -110 }; -111 -112 jasmine.TrivialReporter.prototype.getLocation = function() { -113 return this.document.location; -114 }; -115 -116 jasmine.TrivialReporter.prototype.specFilter = function(spec) { -117 var paramMap = {}; -118 var params = this.getLocation().search.substring(1).split('&'); -119 for (var i = 0; i < params.length; i++) { -120 var p = params[i].split('='); -121 paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); -122 } -123 -124 if (!paramMap["spec"]) return true; -125 return spec.getFullName().indexOf(paramMap["spec"]) == 0; -126 }; -127 -128 //protect against console.log incidents -129 if (!("console" in window) || !("firebug" in console)) { -130 var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; -131 window.console = {}; -132 for (var i = 0, len = names.length; i < len; ++i) { -133 window.console[names[i]] = function() { -134 }; -135 } -136 } -137 \ No newline at end of file +105 jasmine.TrivialReporter.prototype.getLocation = function() { +106 return this.document.location; +107 }; +108 +109 jasmine.TrivialReporter.prototype.specFilter = function(spec) { +110 var paramMap = {}; +111 var params = this.getLocation().search.substring(1).split('&'); +112 for (var i = 0; i < params.length; i++) { +113 var p = params[i].split('='); +114 paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); +115 } +116 +117 if (!paramMap["spec"]) return true; +118 return spec.getFullName().indexOf(paramMap["spec"]) == 0; +119 }; +120 +121 //protect against console.log incidents +122 if (!("console" in window) || !("firebug" in console)) { +123 var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; +124 window.console = {}; +125 for (var i = 0, len = names.length; i < len; ++i) { +126 window.console[names[i]] = function() { +127 }; +128 } +129 } +130 \ No newline at end of file diff --git a/doc/symbols/src/lib_jasmine-0.10.0.js.html b/doc/symbols/src/lib_jasmine-0.10.0.js.html index 1d3f0b1..52d80e4 100644 --- a/doc/symbols/src/lib_jasmine-0.10.0.js.html +++ b/doc/symbols/src/lib_jasmine-0.10.0.js.html @@ -537,7 +537,7 @@ 530 "major": 0, 531 "minor": 10, 532 "build": 0, -533 "revision": 1256686889 +533 "revision": 1256706987 534 }; 535 /** 536 * @namespace diff --git a/lib/TrivialReporter.js b/lib/TrivialReporter.js index dbc1795..eb62924 100644 --- a/lib/TrivialReporter.js +++ b/lib/TrivialReporter.js @@ -17,13 +17,7 @@ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarA } for (var attr in attrs) { - if (attr == 'className') { - el.setAttribute('class', attrs[attr]); - //twice for ie - el.setAttribute('className', attrs[attr]); - } else { el[attr] = attrs[attr]; - } } return el; @@ -101,7 +95,6 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); } } - this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); }; diff --git a/lib/jasmine-0.10.0.js b/lib/jasmine-0.10.0.js index 2b7e4ba..952274a 100644 --- a/lib/jasmine-0.10.0.js +++ b/lib/jasmine-0.10.0.js @@ -530,7 +530,7 @@ jasmine.version_= { "major": 0, "minor": 10, "build": 0, - "revision": 1256687337 + "revision": 1256707024 }; /** * @namespace diff --git a/spec/suites/TrivialReporterSpec.js b/spec/suites/TrivialReporterSpec.js index 750c33f..eae27fe 100644 --- a/spec/suites/TrivialReporterSpec.js +++ b/spec/suites/TrivialReporterSpec.js @@ -8,19 +8,21 @@ describe("TrivialReporter", function() { function fakeSpec(name) { return { - getFullName: function() { return name; } + getFullName: function() { + return name; + } }; } it("should run only specs beginning with spec parameter", function() { - trivialReporter = new jasmine.TrivialReporter({ location: {search: "?spec=run%20this"} }); + var trivialReporter = new jasmine.TrivialReporter({ location: {search: "?spec=run%20this"} }); expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy(); expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy(); expect(trivialReporter.specFilter(fakeSpec("not run this"))).toBeFalsy(); }); it("should display empty divs for every suite when the runner is starting", function() { - trivialReporter = new jasmine.TrivialReporter({ body: body }); + var trivialReporter = new jasmine.TrivialReporter({ body: body }); trivialReporter.reportRunnerStarting({ suites: function() { return [ new jasmine.Suite({}, "suite 1", null, null) ]; @@ -31,5 +33,47 @@ describe("TrivialReporter", function() { expect(divs.length).toEqual(2); expect(divs[1].innerHTML).toContain("suite 1"); }); - + + describe('Matcher reporting', function () { + var getResultMessageDiv = function (body) { + var divs = body.getElementsByTagName("div"); + for (var i = 0; i < divs.length; i++) { + if (divs[i].className.match(/resultMessage/)) { + return divs[i]; + } + } + }; + + var runner, spec, fakeTimer; + beforeEach(function () { + var env = new jasmine.Env(); + fakeTimer = new jasmine.FakeTimer(); + env.setTimeout = fakeTimer.setTimeout; + env.clearTimeout = fakeTimer.clearTimeout; + env.setInterval = fakeTimer.setInterval; + env.clearInterval = fakeTimer.clearInterval; + runner = env.currentRunner(); + var suite = new jasmine.Suite(env, 'some suite'); + runner.add(suite); + spec = new jasmine.Spec(env, suite, 'some spec'); + suite.add(spec); + var trivialReporter = new jasmine.TrivialReporter({ body: body, location: {search: "?"} }); + env.addReporter(trivialReporter); + }); + + describe('toContain', function () { + it('should show actual and expected', function () { + spec.runs(function () { + this.expect('foo').toContain('bar'); + }); + runner.execute(); + fakeTimer.tick(0); + + var resultEl = getResultMessageDiv(body); + expect(resultEl.innerHTML).toMatch(/foo/); + expect(resultEl.innerHTML).toMatch(/bar/); + }); + }); + }); + }); \ No newline at end of file