diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 9dbd5d4e..ca98bd43 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -562,8 +562,8 @@ getJasmineRequireObj().Env = function(j$) { return topSuite; }; - this.execute = function() { - var runnablesToRun = [topSuite.id]; + this.execute = function(runnablesToRun) { + runnablesToRun = runnablesToRun || [topSuite.id]; var allFns = []; for(var i = 0; i < runnablesToRun.length; i++) { diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index f6871f1a..ab8f2149 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -460,6 +460,44 @@ describe("Env integration", function() { env.execute(); }); + + + it("Allows specifying which specs and suites to run", function(done) { + var env = new j$.Env(), + calls = [], + suiteCallback = jasmine.createSpy('suite callback'), + firstSpec, + secondSuite; + + var assertions = function() { + expect(calls).toEqual([ + 'third spec', + 'first spec' + ]); + expect(suiteCallback).toHaveBeenCalled(); + done(); + }; + + env.addReporter({jasmineDone: assertions, suiteDone: suiteCallback}); + + env.describe("first suite", function() { + firstSpec = env.it("first spec", function() { + calls.push('first spec'); + }); + env.it("second spec", function() { + calls.push('second spec'); + }); + }); + + secondSuite = env.describe("second suite", function() { + env.it("third spec", function() { + calls.push('third spec'); + }); + }); + + env.execute([secondSuite.id, firstSpec.id]); + }); + it("Functions can be spied on and have their calls tracked", function (done) { var env = new j$.Env(); diff --git a/src/core/Env.js b/src/core/Env.js index a6d61e00..0faba997 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -193,8 +193,8 @@ getJasmineRequireObj().Env = function(j$) { return topSuite; }; - this.execute = function() { - var runnablesToRun = [topSuite.id]; + this.execute = function(runnablesToRun) { + runnablesToRun = runnablesToRun || [topSuite.id]; var allFns = []; for(var i = 0; i < runnablesToRun.length; i++) {