Skip to content

Commit

Permalink
(minor) naming/style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jul 2, 2010
1 parent db57e70 commit e8cf93e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
28 changes: 15 additions & 13 deletions bin/vows
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ var path = require('path'),
events = require('events');

//
// Attempt to load Coffee-Script. If it's not available, continue on our
// Attempt to load Coffee-Script. If it's not available, continue on our
// merry way, if it is available, set it up so we can include `*.coffee`
// scripts and start searching for them.
//
var fileExt, specFileExt;

try {
var coffee = require('coffee-script');
require.registerExtension('.coffee', function(content) { return coffee.compile(content); });
var fileExtRegex = /\.(js|coffee)$/,
specFileExtRegex = /-(test|spec)\.(js|coffee)$/;
} catch (err) {
var fileExtRegex = /\.js$/,
specFileExtRegex = /-(test|spec)\.js$/;
require.registerExtension('.coffee', function (content) { return coffee.compile(content) });
fileExt = /\.(js|coffee)$/;
specFileExt = /-(test|spec)\.(js|coffee)$/;
} catch (_) {
fileExt = /\.js$/;
specFileExt = /-(test|spec)\.js$/;
}

var inspect = require('eyes').inspector({
Expand Down Expand Up @@ -180,7 +182,7 @@ if (! options.watch) {
reporter.reset = function () { _reporter.reset && _reporter.reset() };

files = args.map(function (a) {
return path.join(process.cwd(), a.replace(fileExtRegex, ''));
return path.join(process.cwd(), a.replace(fileExt, ''));
});

runSuites(importSuites(files), function (results) {
Expand Down Expand Up @@ -264,8 +266,8 @@ if (! options.watch) {

msg('watcher', 'detected change in', file);

file = (specFileExtRegex.test(file) ? path.join(testFolder, file)
: path.join(testFolder, file + '-' + testFolder));
file = (specFileExt.test(file) ? path.join(testFolder, file)
: path.join(testFolder, file + '-' + testFolder));

try {
fs.statSync(file);
Expand All @@ -274,8 +276,8 @@ if (! options.watch) {
file = null;
}

var files = (specFileExtRegex.test(file) ? [file] : paths(testFolder)).map(function (p) {
return path.join(process.cwd(), p.replace(fileExtRegex, ''));
var files = (specFileExt.test(file) ? [file] : paths(testFolder)).map(function (p) {
return path.join(process.cwd(), p.replace(fileExt, ''));
}).map(function (p) {
delete(require.main.moduleCache[p]);
return p;
Expand Down Expand Up @@ -366,7 +368,7 @@ function paths(dir) {

if (file[0] == '.' || file === 'vendor') {
return;
} else if (stat.isFile() && fileExtRegex.test(file)) {
} else if (stat.isFile() && fileExt.test(file)) {
paths.push(path);
} else if (stat.isDirectory()) {
traverse(file, stack);
Expand Down
7 changes: 3 additions & 4 deletions test/vows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,19 @@ vows.describe("Vows").addBatch({
vows.describe("Vows with a single batch", {
"This is a batch that's added as the optional parameter to describe()": {
topic: true,
"A batch added without calling addBatch()": function() {}
"And a vow": function () {}
}
}).export(module);


vows.describe("Vows with multiple batches added as optional parameters", {
"First batch": {
topic: true,
"should be run first": function() {}
"should be run first": function () {}
}
}, {
"Second batch": {
topic: true,
"should be run second": function() {}
"should be run second": function () {}
}
}).export(module);

0 comments on commit e8cf93e

Please sign in to comment.