From 413be6b4ca924bc673a2f5b74028f7fb16a00f88 Mon Sep 17 00:00:00 2001 From: Lee Byrd & Christian Williams Date: Tue, 22 Jun 2010 17:35:41 -0700 Subject: [PATCH] Remove deprecated class jasmine.Reporters. Fully deprecate old-style Matchers; will be removed in next major version. --- spec/runner.html | 1 - spec/suites/CustomMatchersSpec.js | 24 ----------------- spec/suites/MatchersSpec.js | 16 ----------- spec/suites/ReporterSpec.js | 24 +++++++---------- src/Matchers.js | 18 ++----------- src/Reporters.js | 44 ------------------------------- 6 files changed, 12 insertions(+), 115 deletions(-) delete mode 100644 src/Reporters.js diff --git a/spec/runner.html b/spec/runner.html index 416cd51..ed47b96 100644 --- a/spec/runner.html +++ b/spec/runner.html @@ -22,7 +22,6 @@ - diff --git a/spec/suites/CustomMatchersSpec.js b/spec/suites/CustomMatchersSpec.js index 5d49115..c7d3cf6 100644 --- a/spec/suites/CustomMatchersSpec.js +++ b/spec/suites/CustomMatchersSpec.js @@ -85,28 +85,4 @@ describe("Custom Matchers", function() { expect(matcherCallArgs).toEqual([[], ['arg'], ['arg1', 'arg2']]); }); - - describe("in the old style", function() { - it("should report a deprecation error", function() { - var spec; - var suite = env.describe('some suite', function() { - spec = env.it('spec with an expectation').runs(function () { - this.addMatchers({ - toBeTrue: function() { - this.report(this.actual === true, this.actual + " was not true.", "details"); - } - }); - this.expect(true).toBeTrue(); - this.expect(false).toBeTrue(); - }); - }); - - suite.execute(); - var passResult = new jasmine.ExpectationResult({passed: true, message: "Passed.", details: "details"}); - var failResult = new jasmine.ExpectationResult({passed: false, message: "false was not true.", details: "details"}); - failResult.trace = jasmine.any(Object); - expect(spec.results().getItems()).toEqual([passResult, failResult]); - }); - }); - }); \ No newline at end of file diff --git a/spec/suites/MatchersSpec.js b/spec/suites/MatchersSpec.js index ec83ba4..7088614 100644 --- a/spec/suites/MatchersSpec.js +++ b/spec/suites/MatchersSpec.js @@ -523,22 +523,6 @@ describe("jasmine.Matchers", function() { match(false).not.custom(); expect(lastResult().message).toEqual("Passed."); }); - - it("should make old-style custom matchers blow up, but only when negated", function() { - spec.addMatchers({ - custom: function() { - this.report(); - } - }); - - expect(function() { - match(true).custom(); - }).not.toThrow(); - - expect(function() { - match(true).not.custom(); - }).toThrow(); - }); }); describe("spy matchers >>", function() { diff --git a/spec/suites/ReporterSpec.js b/spec/suites/ReporterSpec.js index 4020530..26cdd17 100644 --- a/spec/suites/ReporterSpec.js +++ b/spec/suites/ReporterSpec.js @@ -33,20 +33,16 @@ describe('jasmine.Reporter', function() { var bar = 0; var baz = 0; - var specCallback = function (results) { - foo++; - }; - var suiteCallback = function (results) { - bar++; - }; - var runnerCallback = function (results) { - baz++; - }; - - env.reporter = jasmine.Reporters.reporter({ - specCallback: specCallback, - suiteCallback: suiteCallback, - runnerCallback: runnerCallback + env.addReporter({ + reportSpecResults: function() { + foo++; + }, + reportSuiteResults: function() { + bar++; + }, + reportRunnerResults: function() { + baz++; + } }); var runner = env.currentRunner(); diff --git a/src/Matchers.js b/src/Matchers.js index 8219336..f74eac6 100644 --- a/src/Matchers.js +++ b/src/Matchers.js @@ -15,25 +15,11 @@ jasmine.Matchers = function(env, actual, spec, opt_isNot) { // 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!"); - this.report(); }; -/** @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. */ +// 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) { - // todo: report a deprecation warning [xw] - - if (this.isNot) { - throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); - } - - this.reportWasCalled_ = true; - var expectationResult = new jasmine.ExpectationResult({ - passed: result, - message: failing_message, - details: details - }); - this.spec.addMatcherResult(expectationResult); - return result; + throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); }; jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { diff --git a/src/Reporters.js b/src/Reporters.js deleted file mode 100644 index a353385..0000000 --- a/src/Reporters.js +++ /dev/null @@ -1,44 +0,0 @@ -/** JasmineReporters.reporter - * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to - * descendants of this object to do something with the results (see json_reporter.js) - * - * @deprecated - */ -jasmine.Reporters = {}; - -/** - * @deprecated - * @param callbacks - */ -jasmine.Reporters.reporter = function(callbacks) { - /** - * @deprecated - * @param callbacks - */ - var that = { - callbacks: callbacks || {}, - - doCallback: function(callback, results) { - if (callback) { - callback(results); - } - }, - - reportRunnerResults: function(runner) { - that.doCallback(that.callbacks.runnerCallback, runner); - }, - reportSuiteResults: function(suite) { - that.doCallback(that.callbacks.suiteCallback, suite); - }, - reportSpecResults: function(spec) { - that.doCallback(that.callbacks.specCallback, spec); - }, - log: function (str) { - var console = jasmine.getGlobal().console; - if (console && console.log) console.log(str); - } - }; - - return that; -}; -