diff --git a/lib/TrivialReporter.js b/lib/TrivialReporter.js index f796cf08..b4058216 100644 --- a/lib/TrivialReporter.js +++ b/lib/TrivialReporter.js @@ -1,6 +1,7 @@ jasmine.TrivialReporter = function(doc) { this.document = doc || document; this.suiteDivs = {}; + this.logRunningSpecs = false; }; jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) { @@ -115,6 +116,12 @@ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { 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'; diff --git a/spec/suites/MultiReporterSpec.js b/spec/suites/MultiReporterSpec.js index 0a82ee0c..ea67aaa9 100644 --- a/spec/suites/MultiReporterSpec.js +++ b/spec/suites/MultiReporterSpec.js @@ -10,11 +10,26 @@ describe("jasmine.MultiReporter", function() { }); it("should support all the method calls that jasmine.Reporter supports", function() { - multiReporter.reportRunnerStarting(); - multiReporter.reportRunnerResults(); - multiReporter.reportSuiteResults(); - multiReporter.reportSpecResults(); - multiReporter.log(); + var delegate = {}; + multiReporter.addReporter(delegate); + + this.addMatchers({ + toDelegateMethod: function(methodName) { + delegate[methodName] = jasmine.createSpy(methodName); + this.actual[methodName]("whatever argument"); + + return delegate[methodName].wasCalled + && delegate[methodName].mostRecentCall.args.length == 1 + && delegate[methodName].mostRecentCall.args[0] == "whatever argument"; + } + }); + + expect(multiReporter).toDelegateMethod('reportRunnerStarting'); + expect(multiReporter).toDelegateMethod('reportRunnerResults'); + expect(multiReporter).toDelegateMethod('reportSuiteResults'); + expect(multiReporter).toDelegateMethod('reportSpecStarting'); + expect(multiReporter).toDelegateMethod('reportSpecResults'); + expect(multiReporter).toDelegateMethod('log'); }); it("should delegate to any and all subreporters", function() { diff --git a/spec/suites/TrivialReporterSpec.js b/spec/suites/TrivialReporterSpec.js index 237bf476..2470bb59 100644 --- a/spec/suites/TrivialReporterSpec.js +++ b/spec/suites/TrivialReporterSpec.js @@ -205,4 +205,31 @@ describe("TrivialReporter", function() { expect(failedSpecDiv.innerHTML).not.toContain("this one passes!"); }); }); + + describe('#reportSpecStarting', function() { + var spec1; + beforeEach(function () { + env.describe("suite 1", function() { + spec1 = env.it("spec 1", function() { + }); + }); + }); + + it('DOES NOT log running specs by default', function() { + spyOn(trivialReporter, 'log'); + + trivialReporter.reportSpecStarting(spec1); + + expect(trivialReporter.log).not.toHaveBeenCalled(); + }); + + it('logs running specs when log_running_specs is true', function() { + trivialReporter.logRunningSpecs = true; + spyOn(trivialReporter, 'log'); + + trivialReporter.reportSpecStarting(spec1); + + expect(trivialReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...'); + }); + }); }); diff --git a/spec/suites/WaitsForBlockSpec.js b/spec/suites/WaitsForBlockSpec.js index f6cd1092..73572c6f 100644 --- a/spec/suites/WaitsForBlockSpec.js +++ b/spec/suites/WaitsForBlockSpec.js @@ -82,7 +82,6 @@ describe('WaitsForBlock', function () { var failMessage = spec.fail.mostRecentCall.args[0].message; expect(failMessage).toMatch(message); expect(onComplete).wasNotCalled(); - }); }); }); \ No newline at end of file diff --git a/src/MultiReporter.js b/src/MultiReporter.js index cb8110ae..a47650e3 100644 --- a/src/MultiReporter.js +++ b/src/MultiReporter.js @@ -11,7 +11,14 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) { }; (function() { - var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"]; + 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) { diff --git a/src/Reporter.js b/src/Reporter.js index 06f8c344..7bfc669b 100644 --- a/src/Reporter.js +++ b/src/Reporter.js @@ -17,6 +17,10 @@ jasmine.Reporter.prototype.reportRunnerResults = function(runner) { jasmine.Reporter.prototype.reportSuiteResults = function(suite) { }; +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSpecStarting = function(spec) { +}; + //noinspection JSUnusedLocalSymbols jasmine.Reporter.prototype.reportSpecResults = function(spec) { }; diff --git a/src/Spec.js b/src/Spec.js index cdedb0be..98828bb6 100644 --- a/src/Spec.js +++ b/src/Spec.js @@ -134,7 +134,8 @@ jasmine.Spec.prototype.execute = function(onComplete) { spec.finish(onComplete); return; } - this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); + + this.env.reporter.reportSpecStarting(this); spec.env.currentSpec = spec;