Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:mhevery/jasmine-node

  • Loading branch information...
commit 796c12076a8e3ce594d4d596345487b2dc46f209 2 parents 7cb1e6f + d32678c
Chris Moultrie authored
5 README.md
View
@@ -14,7 +14,7 @@ Version `1.3.1` of Jasmine is currently included with node-jasmine.
what's new
----------
-* Growl notifications with the `--growl` flat (requires Growl to be installed)
+* Growl notifications with the `--growl` flag (requires Growl to be installed)
* Ability to test specs written in Literate Coffee-Script
* Teamcity Reporter reinstated.
* Ability to specify multiple files to test via list in command line
@@ -47,7 +47,8 @@ usage
------
Write the specifications for your code in `*.js` and `*.coffee` files in the `spec/` directory.
-You can use sub-directories to better organise your specs.
+You can use sub-directories to better organise your specs. In the specs use `describe()`, `it()` etc. exactly
+as you would in client-side jasmine specs.
**Note**: your specification files must be named as `*spec.js`, `*spec.coffee` or `*spec.litcoffee`,
which matches the regular expression `/spec\.(js|coffee|litcoffee)$/i`;
18 bower.json
View
@@ -0,0 +1,18 @@
+{
+ "name": "jasmine-node",
+ "version": "1.11.0",
+ "homepage": "https://github.com/mhevery/jasmine-node",
+ "authors": [
+ "Chris M <http://www.endgame.com"
+ ],
+ "description": "Integration of Jasmine Spec framework with Node.js",
+ "main": "lib/jasmine-node",
+ "keywords": [
+ "jasmine",
+ "node",
+ "commonjs",
+ "node"
+ ],
+ "license": "MIT",
+ "private": true
+}
13 lib/jasmine-node/autotest.js 100644 → 100755
View
@@ -27,14 +27,16 @@ var run_external = function(command, args, callback) {
}
}
+var last_run_successful = false;
+
var run_everything = function() {
// run the suite when it starts
var argv = [].concat(baseArgv);
- run_external(argv.shift(), argv);
+ run_external(argv.shift(), argv, function (code) {
+ last_run_successful = code === 0
+ });
}
-var last_run_succesful = true;
-
exports.start = function(loadpaths, watchFolders, patterns) {
var watchPatterns;
@@ -60,12 +62,11 @@ exports.start = function(loadpaths, watchFolders, patterns) {
run_external(argv.shift(), argv, function(code) {
// run everything if we fixed some bugs
if(code == 0) {
- if(!last_run_succesful) {
+ if(!last_run_successful) {
run_everything();
}
- last_run_succesful = true;
} else {
- last_run_succesful = false;
+ last_run_successful = false;
}
});
}
20 lib/jasmine-node/index.js
View
@@ -37,26 +37,34 @@ jasmine.TerminalReporter = nodeReporters.TerminalReporter;
jasmine.GrowlReporter = require('jasmine-growl-reporter');
-jasmine.loadHelpersInFolder=function(folder, matcher)
-{
+jasmine.loadHelpersInFolder = function(folder, matcher) {
// Check to see if the folder is actually a file, if so, back up to the
// parent directory and find some helpers
folderStats = fs.statSync(folder);
if (folderStats.isFile()) {
folder = path.dirname(folder);
}
+
var helpers = [],
helperCollection = require('./spec-collection');
helperCollection.load([folder], matcher);
helpers = helperCollection.getSpecs();
- for (var i = 0, len = helpers.length; i < len; ++i)
- {
+ for (var i = 0, len = helpers.length; i < len; ++i) {
var file = helpers[i].path();
- var helper= require(file.replace(/\.*$/, ""));
- for (var key in helper)
+
+ try {
+ var helper = require(file.replace(/\.*$/, ""));
+ } catch (e) {
+ console.log("Exception loading helper: " + file)
+ console.log(e);
+ throw e; // If any of the helpers fail to load, fail everything
+ }
+
+ for (var key in helper) {
global[key]= helper[key];
+ }
}
};
9 lib/jasmine-node/requirejs-runner.js
View
@@ -67,20 +67,19 @@ exports.executeJsRunner = function(specCollection, done, jasmineEnv, setupFile)
};
specCollection.getSpecs().forEach(function(s){
- var script = fs.readFileSync(s.path(), 'utf8'),
- wrappedScript;
+ var script = fs.readFileSync(s.path(), 'utf8');
if (s.filename().substr(-6).toLowerCase() == 'coffee') {
script = coffeescript.compile(script);
}
- wrappedScript = template + script;
-
var newContext = buildNewContext(s);
newContext.setTimeout = jasmine.getGlobal().setTimeout;
newContext.setInterval = jasmine.getGlobal().setInterval;
- vm.runInNewContext(wrappedScript, newContext, s.path());
+ var vmContext = vm.createContext(newContext);
+ vm.runInContext(template, vmContext);
+ vm.runInContext(script, vmContext, s.path());
});
specLoader.executeWhenAllSpecsAreComplete(jasmineEnv);
Please sign in to comment.
Something went wrong with that request. Please try again.