From a9a6d7cbda7cf1ebf08cd7563f7d188d7bda4aa0 Mon Sep 17 00:00:00 2001 From: pivotal Date: Tue, 2 Dec 2008 14:26:47 -0800 Subject: [PATCH] dwf/rva: results are now carrying descriptions as needed (Runner, Suite, Spec) --- jasmine.iws | 34 +++++++++++++++++----------------- lib/jasmine.js | 14 +++++++------- test/bootstrap.js | 25 +++++++++++++++---------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/jasmine.iws b/jasmine.iws index c5402ca..49b59ea 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -80,7 +80,7 @@ - + @@ -89,10 +89,10 @@ - + - + @@ -101,16 +101,16 @@ - + - + - + @@ -313,7 +313,7 @@ - + @@ -434,7 +434,7 @@ - + @@ -444,21 +444,21 @@ - - - - - - - - + - + + + + + + + + diff --git a/lib/jasmine.js b/lib/jasmine.js index 4ae9f74..b2f22ec 100755 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -158,10 +158,6 @@ var it = function (description, func) { currentTimeout: 0, finished: false, -// suite: { -// next: function() { -// }}, - results: nestedResults(), expects_that: function (actual) { @@ -213,6 +209,7 @@ var it = function (description, func) { func(); } + that.results.description = description; return that; } @@ -236,7 +233,9 @@ var describe = function (description, spec_definitions) { currentRunner.suites.push(that); spec_definitions(); - + + that.results.description = description; + return that; } @@ -244,6 +243,7 @@ var Jasmine = function () { var that = actionCollection(); that.suites = that.actions; + that.results.description = 'All Jasmine Suites'; currentRunner = that; return that; @@ -256,7 +256,7 @@ var currentSpec; /* * TODO: - * - add spec or description to results + //* - add spec or description to results //* - spec.execute needs to wait until the spec is done //* - an async test will be killed after X ms if not done and then listed as failed with an "async fail" message of some sort //* - Suite to run tests in order, constructed with a function called describe @@ -267,7 +267,7 @@ var currentSpec; //* - Suite rolls up spec results //* - Suite supports asynch //* - Runner that runs suites in order -// * - Runner supports async + //* - Runner supports async * - HTML reporter * - Shows pass/fail progress (just like bootstrap reporter) * - Lists a Summary: total # specs, # of passed, # of failed diff --git a/test/bootstrap.js b/test/bootstrap.js index 0a96063..032fbbb 100755 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -69,21 +69,21 @@ var testMatchersReporting = function () { reporter.test((results.length == 2), "Results array doesn't have 2 results"); - reporter.test((results[0].passed == true), + reporter.test((results[0].passed === true), "First spec didn't pass"); - reporter.test((results[1].passed == false), + reporter.test((results[1].passed === false), "Second spec did pass"); results = []; - var expected = new Matchers(false, results); + expected = new Matchers(false, results); expected.should_equal(true); reporter.test((results[0].message == 'Expected true but got false.'), "Failed expectation didn't test the failure message"); results = []; - var expected = new Matchers(true, results); + expected = new Matchers(true, results); expected.should_equal(true); reporter.test((results[0].message == 'Passed.'), @@ -102,10 +102,12 @@ var testSpecs = function () { another_spec.execute(); another_spec.done = true; - reporter.test((another_spec.results.results.length == 1), + reporter.test((another_spec.results.results.length === 1), "Results aren't there after a spec was executed"); - reporter.test((another_spec.results.results[0].passed == true), + reporter.test((another_spec.results.results[0].passed === true), "Results has a result, but it's true"); + reporter.test((another_spec.results.description === 'spec with an expectation'), + "Spec's results did not get the spec's description"); var yet_another_spec = it('spec with failing expectation').runs(function () { var foo = 'bar'; @@ -114,7 +116,7 @@ var testSpecs = function () { yet_another_spec.execute(); yet_another_spec.done = true; - reporter.test((yet_another_spec.results.results[0].passed == false), + reporter.test((yet_another_spec.results.results[0].passed === false), "Expectation that failed, passed"); var yet_yet_another_spec = it('spec with multiple assertions').runs(function () { @@ -127,7 +129,7 @@ var testSpecs = function () { yet_yet_another_spec.execute(); yet_yet_another_spec.done = true; - reporter.test((yet_yet_another_spec.results.results.length == 2), + reporter.test((yet_yet_another_spec.results.results.length === 2), "Spec doesn't support multiple expectations"); } @@ -395,6 +397,8 @@ var testSpecScope = function () { "Spec did not return false for a failed expectation"); reporter.test((suite.specs[0].results.results[1].passed === true), "Spec did not return true for a passing expectation"); + reporter.test((suite.results.description === 'one suite description'), + "Suite did not get its description in the results"); }, 1000); } @@ -495,7 +499,6 @@ var testNestedResults = function () { "Branch Results should have 2 passed, has " + branchResults.passedCount); reporter.test((branchResults.failedCount === 2), "Branch Results should have 2 failed, has " + branchResults.failedCount); - } var testReporting = function () { @@ -525,6 +528,8 @@ var testReporting = function () { 'Expectation Passed count should be 1, but was ' + runner.results.passedCount); reporter.test((runner.results.failedCount === 1), 'Expectation Failed count should be 1, but was ' + runner.results.failedCount); + reporter.test((runner.results.description === 'All Jasmine Suites'), + 'Jasmine Runner does not have the expected description, has: ' + runner.results.description); }, 1000); } @@ -546,7 +551,7 @@ var runTests = function () { setTimeout(function() { $('spinner').hide(); reporter.summary(); - }, 10000); + }, 3500); }