Throw error if you define a spy outside of a runnable

[#66789174]
This commit is contained in:
Christopher Amavisca and Greg Cobb
2014-03-05 14:27:19 -08:00
parent b200952195
commit a2ac5ef3b6
3 changed files with 29 additions and 0 deletions

View File

@@ -802,4 +802,27 @@ describe("Env integration", function() {
env.execute();
});
it('throws an exception if you try to create a spy outside of a runnable', function (done) {
var env = new j$.Env(),
obj = {fn: function () {}},
exception;
env.describe("a suite", function () {
try {
env.spyOn(obj, 'fn');
} catch(e) {
exception = e;
}
});
var assertions = function() {
expect(exception.message).toBe('Spies must be created in a before function or a spec');
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});