Skip to content
Browse files

Fixes for use with requirejs

  • Loading branch information...
1 parent b71a789 commit 441aeb18ed6cdcf4926d5952355e642b0bb1a0df Matthew Smith committed Mar 5, 2012
Showing with 20 additions and 27 deletions.
  1. +0 −6 lib/jasmine-node/cli.js
  2. +2 −2 lib/jasmine-node/requirejs-runner.js
  3. +18 −19 lib/jasmine-node/spec-collection.js
View
6 lib/jasmine-node/cli.js
@@ -140,12 +140,6 @@ if(useHelpers){
var regExpSpec = new RegExp(match + (matchall ? "" : "spec\\.") + "(" + extentions + ")$", 'i')
-helperCollection.load(specFolder, regExpSpec);
-
-if(helperCollection.getSpecs().length === 0) {
- match = "";
-}
-
jasmine.executeSpecsInFolder(specFolder,
onComplete,
isVerbose,
View
4 lib/jasmine-node/requirejs-runner.js
@@ -25,13 +25,13 @@ exports.executeJsRunner = function(specCollection, done, jasmineEnv) {
thisDir = process.cwd();//.replace(/.:/, '\\c').split('\\'),
toDir = dir.split('/'),
index = 0,
- colonMatches = __dirname.match(/.:/);
+ colonMatches = __dirname.match(/^.:/);
for(var i = 0; i < (colonMatches && colonMatches.length) || 0; i++){
thisDir = thisDir.replace(colonMatches[i], '\\' + colonMatches[i].substring(0,1));
}
- thisDir = thisDir.split('\\');
+ thisDir = thisDir.replace(/\\/g, '/').split('/');
for(; index < thisDir.length || index < toDir.length; index++) {
if(thisDir[index] != toDir[index]){
View
37 lib/jasmine-node/spec-collection.js
@@ -4,31 +4,30 @@ var fs = require('fs');
var specs = [];
var createSpecObj = function(path, root) {
- return {
- path: function() { return path; },
- relativePath: function() { return path.replace(root, '').replace(/^[\/\\]/, ''); },
- directory: function() { return path.replace(/[\/\\][\s\w\.-]*$/, ""); },
- relativeDirectory: function() { return relativePath().replace(/[\/\\][\s\w\.-]*$/, ""); },
- filename: function() { return path.replace(/^.*[\\\/]/, ''); }
- };
+ return {
+ path: function() { return path; },
+ relativePath: function() { return path.replace(root, '').replace(/^[\/\\]/, '').replace(/\\/g, '/'); },
+ directory: function() { return path.replace(/[\/\\][\s\w\.-]*$/, "").replace(/\\/g, '/'); },
+ relativeDirectory: function() { return relativePath().replace(/[\/\\][\s\w\.-]*$/, "").replace(/\\/g, '/'); },
+ filename: function() { return path.replace(/^.*[\\\/]/, ''); }
+ };
};
exports.load = function(loadpath, matcher) {
+ var wannaBeSpecs = walkdir.sync(loadpath)
- var wannaBeSpecs = walkdir.sync(loadpath)
-
- for (var i = 0; i < wannaBeSpecs.length; i++) {
- var file = wannaBeSpecs[i];
- try {
- if (fs.statSync(file).isFile()) {
- if (!/.*node_modules.*/.test(file) && matcher.test(path.basename(file))) {
- specs.push(createSpecObj(file));
- }
- }
- } catch(e) {
- // nothing to do here
+ for (var i = 0; i < wannaBeSpecs.length; i++) {
+ var file = wannaBeSpecs[i];
+ try {
+ if (fs.statSync(file).isFile()) {
+ if (!/.*node_modules.*/.test(file) && matcher.test(path.basename(file))) {
+ specs.push(createSpecObj(file));
}
+ }
+ } catch(e) {
+ // nothing to do here
}
+ }
};
exports.getSpecs = function() {

0 comments on commit 441aeb1

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