diff --git a/lib/jasmine.js b/lib/jasmine.js index 1516e7a..acd93c1 100644 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -1917,7 +1917,7 @@ jasmine.Spec = function(env, suite, description) { }; jasmine.Spec.prototype.getFullName = function() { - var description = (this.description.apply ? this.description.name : this.description); + var description = (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description; return this.suite.getFullName() + ' ' + description + '.'; }; @@ -2154,13 +2154,17 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) { }; jasmine.Suite.prototype.getFullName = function() { - var fullName = (this.description.apply ? this.description.name : this.description); + var fullName = this.getDescription() for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { - fullName = parentSuite.description + ' ' + fullName; + fullName = parentSuite.getDescription() + ' ' + fullName; } return fullName; }; +jasmine.Suite.prototype.getDescription = function() { + return (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description; +}; + jasmine.Suite.prototype.finish = function(onComplete) { this.env.reporter.reportSuiteResults(this); this.finished = true; @@ -2469,5 +2473,5 @@ jasmine.version_= { "major": 1, "minor": 1, "build": 0, - "revision": 1307455841 + "revision": 1307554069 }; diff --git a/spec/suites/SuiteSpec.js b/spec/suites/SuiteSpec.js index 3b33cf3..6f5302c 100644 --- a/spec/suites/SuiteSpec.js +++ b/spec/suites/SuiteSpec.js @@ -80,6 +80,18 @@ describe('Suite', function() { expect(suite.getFullName()).toEqual("MyClass"); expect(suite.children()[0].getFullName()).toEqual("MyClass should be something."); }); + + it('should use the name of the parent suite correctly', function() { + suite = env.describe(MyClass, function() { + env.describe('nested', function() { + env.it('should be something', function() { + }); + }); + }); + + expect(suite.getFullName()).toEqual("MyClass"); + expect(suite.suites()[0].getFullName()).toEqual("MyClass nested"); + }); }); }); diff --git a/src/core/Spec.js b/src/core/Spec.js index 3569e89..8bea4e6 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -29,7 +29,7 @@ jasmine.Spec = function(env, suite, description) { }; jasmine.Spec.prototype.getFullName = function() { - var description = (this.description.apply ? this.description.name : this.description); + var description = (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description; return this.suite.getFullName() + ' ' + description + '.'; }; diff --git a/src/core/Suite.js b/src/core/Suite.js index a83593a..6c9f529 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -22,13 +22,17 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) { }; jasmine.Suite.prototype.getFullName = function() { - var fullName = (this.description.apply ? this.description.name : this.description); + var fullName = this.getDescription() for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { - fullName = parentSuite.description + ' ' + fullName; + fullName = parentSuite.getDescription() + ' ' + fullName; } return fullName; }; +jasmine.Suite.prototype.getDescription = function() { + return (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description; +}; + jasmine.Suite.prototype.finish = function(onComplete) { this.env.reporter.reportSuiteResults(this); this.finished = true;