diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 0d358a346..7e5531861 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -711,13 +711,17 @@ getJasmineRequireObj().Env = function(j$) { this.describe = function(description, specDefinitions) { var suite = suiteFactory(description); + if (currentDeclarationSuite.markedPending) { + suite.pend(); + } addSpecsToSuite(suite, specDefinitions); return suite; }; this.xdescribe = function(description, specDefinitions) { - var suite = this.describe(description, specDefinitions); - suite.disable(); + var suite = suiteFactory(description); + suite.pend(); + addSpecsToSuite(suite, specDefinitions); return suite; }; @@ -823,6 +827,9 @@ getJasmineRequireObj().Env = function(j$) { this.it = function(description, fn, timeout) { var spec = specFactory(description, fn, currentDeclarationSuite, timeout); + if (currentDeclarationSuite.markedPending) { + spec.pend(); + } currentDeclarationSuite.addChild(spec); return spec; }; @@ -833,9 +840,9 @@ getJasmineRequireObj().Env = function(j$) { return spec; }; - this.fit = function(){ - var spec = this.it.apply(this, arguments); - + this.fit = function(description, fn, timeout){ + var spec = specFactory(description, fn, currentDeclarationSuite, timeout); + currentDeclarationSuite.addChild(spec); focusedRunnables.push(spec.id); unfocusAncestor(); return spec; @@ -2031,6 +2038,10 @@ getJasmineRequireObj().Suite = function(j$) { this.disabled = true; }; + Suite.prototype.pend = function(message) { + this.markedPending = true; + }; + Suite.prototype.beforeEach = function(fn) { this.beforeFns.unshift(fn); }; @@ -2056,6 +2067,10 @@ getJasmineRequireObj().Suite = function(j$) { return 'disabled'; } + if (this.markedPending) { + return 'pending'; + } + if (this.result.failedExpectations.length > 0) { return 'failed'; } else { diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index 6aeb6e53b..c36d1d686 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -90,6 +90,21 @@ describe("Suite", function() { expect(suite.getResult().status).toBe('disabled'); }); + it("retrieves a result with pending status", function() { + var suite = new j$.Suite({}); + suite.pend(); + + expect(suite.getResult().status).toBe('pending'); + }); + + it("priviledges a disabled status over pending status", function() { + var suite = new j$.Suite({}); + suite.disable(); + suite.pend(); + + expect(suite.getResult().status).toBe('disabled'); + }); + it("is executable if not disabled", function() { var suite = new j$.Suite({}); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 0dd00170c..0b24610ac 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1115,6 +1115,78 @@ describe("Env integration", function() { env.execute(); }); + + it('should run focused tests inside an xdescribe', function(done) { + var env = new j$.Env(), + reporter = jasmine.createSpyObj('fakeReporter', [ + "jasmineStarted", + "jasmineDone", + "suiteStarted", + "suiteDone", + "specStarted", + "specDone" + ]); + + reporter.jasmineDone.and.callFake(function() { + expect(reporter.jasmineStarted).toHaveBeenCalledWith({ + totalSpecsDefined: 1 + }); + + expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ + description: 'with a fit spec', + status: 'failed' + })); + + done(); + }); + + env.addReporter(reporter); + + env.xdescribe("xd suite", function() { + env.fit("with a fit spec", function() { + env.expect(true).toBe(false); + }); + }); + + env.execute(); + }); + + it('should run focused suites inside an xdescribe', function(done) { + var env = new j$.Env(), + reporter = jasmine.createSpyObj('fakeReporter', [ + "jasmineStarted", + "jasmineDone", + "suiteStarted", + "suiteDone", + "specStarted", + "specDone" + ]); + + reporter.jasmineDone.and.callFake(function() { + expect(reporter.jasmineStarted).toHaveBeenCalledWith({ + totalSpecsDefined: 1 + }); + + expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ + description: 'with a spec', + status: 'failed' + })); + + done(); + }); + + env.addReporter(reporter); + + env.xdescribe("xd suite", function() { + env.fdescribe("fd suite", function() { + env.it("with a spec", function() { + env.expect(true).toBe(false); + }); + }); + }); + + env.execute(); + }); }); it("should report as expected", function(done) { @@ -1227,9 +1299,10 @@ describe("Env integration", function() { totalSpecsDefined: 1 }); - expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' })); - expect(reporter.suiteDone.calls.count()).toBe(3); - + expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'pending' })); + expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' })); + expect(reporter.suiteDone.calls.count()).toBe(4); + done(); }); @@ -1238,8 +1311,10 @@ describe("Env integration", function() { env.describe("A Suite", function() { env.describe("nested", function() { env.xdescribe("xd out", function() { - env.it("with a spec", function() { - env.expect(true).toBe(false); + env.describe("nested again", function() { + env.it("with a spec", function() { + env.expect(true).toBe(false); + }); }); }); }); diff --git a/src/core/Env.js b/src/core/Env.js index 1754856e4..135dd8391 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -261,13 +261,17 @@ getJasmineRequireObj().Env = function(j$) { this.describe = function(description, specDefinitions) { var suite = suiteFactory(description); + if (currentDeclarationSuite.markedPending) { + suite.pend(); + } addSpecsToSuite(suite, specDefinitions); return suite; }; this.xdescribe = function(description, specDefinitions) { - var suite = this.describe(description, specDefinitions); - suite.disable(); + var suite = suiteFactory(description); + suite.pend(); + addSpecsToSuite(suite, specDefinitions); return suite; }; @@ -373,6 +377,9 @@ getJasmineRequireObj().Env = function(j$) { this.it = function(description, fn, timeout) { var spec = specFactory(description, fn, currentDeclarationSuite, timeout); + if (currentDeclarationSuite.markedPending) { + spec.pend(); + } currentDeclarationSuite.addChild(spec); return spec; }; @@ -383,9 +390,9 @@ getJasmineRequireObj().Env = function(j$) { return spec; }; - this.fit = function(){ - var spec = this.it.apply(this, arguments); - + this.fit = function(description, fn, timeout){ + var spec = specFactory(description, fn, currentDeclarationSuite, timeout); + currentDeclarationSuite.addChild(spec); focusedRunnables.push(spec.id); unfocusAncestor(); return spec; diff --git a/src/core/Suite.js b/src/core/Suite.js index ddf8e1857..81ec5d09e 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -42,6 +42,10 @@ getJasmineRequireObj().Suite = function(j$) { this.disabled = true; }; + Suite.prototype.pend = function(message) { + this.markedPending = true; + }; + Suite.prototype.beforeEach = function(fn) { this.beforeFns.unshift(fn); }; @@ -67,6 +71,10 @@ getJasmineRequireObj().Suite = function(j$) { return 'disabled'; } + if (this.markedPending) { + return 'pending'; + } + if (this.result.failedExpectations.length > 0) { return 'failed'; } else {