Remove deprecated class jasmine.Reporters.

Fully deprecate old-style Matchers; will be removed in next major version.
This commit is contained in:
Lee Byrd & Christian Williams 2010-06-22 17:35:41 -07:00
parent 0539251fe6
commit 413be6b4ca
6 changed files with 12 additions and 115 deletions

View File

@ -22,7 +22,6 @@
<script type="text/javascript" src="../src/NestedResults.js"></script>
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
<script type="text/javascript" src="../src/Queue.js"></script>
<script type="text/javascript" src="../src/Reporters.js"></script>
<script type="text/javascript" src="../src/Runner.js"></script>
<script type="text/javascript" src="../src/Spec.js"></script>
<script type="text/javascript" src="../src/Suite.js"></script>

View File

@ -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]);
});
});
});

View File

@ -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() {

View File

@ -33,20 +33,16 @@ describe('jasmine.Reporter', function() {
var bar = 0;
var baz = 0;
var specCallback = function (results) {
env.addReporter({
reportSpecResults: function() {
foo++;
};
var suiteCallback = function (results) {
},
reportSuiteResults: function() {
bar++;
};
var runnerCallback = function (results) {
},
reportRunnerResults: function() {
baz++;
};
env.reporter = jasmine.Reporters.reporter({
specCallback: specCallback,
suiteCallback: suiteCallback,
runnerCallback: runnerCallback
}
});
var runner = env.currentRunner();

View File

@ -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;
};
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {

View File

@ -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;
};