Skip to content
Browse files

inline jasmine runner call from cli.js

  • Loading branch information...
1 parent 3b2651c commit 7329311ad14b293ab84390bc6fb78c5f3b0cd62f Gregor Gramlich committed Jan 15, 2012
Showing with 66 additions and 3 deletions.
  1. +66 −3 Jakefile
View
69 Jakefile
@@ -5,13 +5,13 @@ desc('Run all jasmine specs from the spec folder');
task('runspecs', [], function () {
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';
- var specFolder = 'spec';
- process.argv.push(specFolder);
loadJsDomAndJQuery(function (window) {
global.theWindow = window;
global.$ = window.jQuery;
- require('jasmine-node/lib/jasmine-node/cli.js');
+ var jasmine = require('jasmine-node/lib/jasmine-node/index');
+ var specFolder = 'spec';
+ runJasmine(jasmine, specFolder);
complete();
});
}, true);
@@ -29,3 +29,66 @@ function loadJsDomAndJQuery(callback) {
callback(window);
});
}
+
+function runJasmine (jasmine, specFolder) {
+ var util,
+ Path= require('path');
+ try {
+ util = require('util')
+ } catch(e) {
+ util = require('sys')
+ }
+
+ specFolder = Path.join(process.cwd(), specFolder);
+
+ for (var key in jasmine)
+ global[key] = jasmine[key];
+
+ var isVerbose = false;
+ var showColors = true;
+ var teamcity = process.env.TEAMCITY_PROJECT_NAME || false;
+ var useRequireJs = false;
+ var extentions = "js";
+ var match = '.';
+ var useHelpers = true;
+
+ var junitreport = {
+ report: false,
+ savePath : "./reports/",
+ useDotNotation: true,
+ consolidate: true
+ }
+
+ var exitCode = 0;
+
+ process.on("exit", onExit);
+
+ function onExit() {
+ process.removeListener("exit", onExit);
+ process.exit(exitCode);
+ }
+
+ var onComplete = function(runner, log) {
+ util.print('\n');
+ if (runner.results().failedCount == 0) {
+ exitCode = 0;
+ } else {
+ exitCode = 1;
+ }
+ };
+
+ if(useHelpers){
+ jasmine.loadHelpersInFolder(specFolder,
+ new RegExp("helpers?\\.(" + extentions + ")$", 'i'));
+ }
+
+ jasmine.executeSpecsInFolder(specFolder,
+ onComplete,
+ isVerbose,
+ showColors,
+ teamcity,
+ useRequireJs,
+ new RegExp(match + "spec\\.(" + extentions + ")$", 'i'),
+ junitreport);
+
+}

0 comments on commit 7329311

Please sign in to comment.
Something went wrong with that request. Please try again.