From 222dda4e067f6a3f35134a37e1fda4946dc379ab Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 7 Jun 2011 09:47:30 -0400 Subject: [PATCH] if a spec description is given a function as the description, use its name as the displayed description --- spec/suites/SpecSpec.js | 20 ++++++++++++++++---- src/core/Spec.js | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/spec/suites/SpecSpec.js b/spec/suites/SpecSpec.js index 1e4a22d..e222222 100644 --- a/spec/suites/SpecSpec.js +++ b/spec/suites/SpecSpec.js @@ -36,9 +36,21 @@ describe('Spec', function () { }); }); - it('getFullName returns suite & spec description', function () { - var spec = new jasmine.Spec(env, suite, 'spec 1'); - expect(spec.getFullName()).toEqual('suite 1 spec 1.'); + describe('full name', function() { + describe('with string', function() { + it('getFullName returns suite & spec description', function () { + var spec = new jasmine.Spec(env, suite, 'spec 1'); + expect(spec.getFullName()).toEqual('suite 1 spec 1.'); + }); + }); + + describe('with class name', function () { + function MyClass() {} + it('getFullName returns suite & spec description', function () { + var spec = new jasmine.Spec(env, suite, MyClass); + expect(spec.getFullName()).toEqual('suite 1 MyClass.'); + }); + }); }); describe('results', function () { @@ -121,4 +133,4 @@ describe('Spec', function () { expect(logResult.values).toEqual(["here's some log message", {key: 'value'}, 123]); }); }); -}); \ No newline at end of file +}); diff --git a/src/core/Spec.js b/src/core/Spec.js index 972ccfd..3569e89 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -29,7 +29,8 @@ jasmine.Spec = function(env, suite, description) { }; jasmine.Spec.prototype.getFullName = function() { - return this.suite.getFullName() + ' ' + this.description + '.'; + var description = (this.description.apply ? this.description.name : this.description); + return this.suite.getFullName() + ' ' + description + '.'; };