Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

Commit

Permalink
Implemented pending spec, exported jezebel settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Bunsch committed May 15, 2011
1 parent 8083779 commit f945eef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
21 changes: 12 additions & 9 deletions lib/jezebel.js
Expand Up @@ -10,6 +10,11 @@ var selector = require('jezebel/test_selector');
var session;
var settings = {};

function startRepl() {
session = repl.start("> ");
session.context.runTests = runTests;
}

function evalInRepl(statement) {
process.stdin.emit('data', new Buffer(statement));
}
Expand All @@ -18,7 +23,7 @@ function runHook(name, args) {
func = settings["on" + name];
if (func) {
return func.apply(session.context, args);
}
}
}

function fileChanged(path, curr, prev) {
Expand All @@ -35,7 +40,7 @@ function runTests(tests) {
var child = childProcess.spawn(binDir + '/jessie', tests);
child.stdout.addListener("data", function (chunk) { chunk && sys.print(chunk) });
child.stderr.addListener("data", function (chunk) { chunk && sys.debug(chunk) });
child.on('exit', function(fail) {
child.on('exit', function(fail) {
if (fail) {
runHook('Fail');
} else {
Expand All @@ -48,8 +53,8 @@ function runTests(tests) {
function loadConfig(callback) {
var configFile = process.cwd() + '/.jezebel';
path.exists(configFile, function(exists) {
if (exists) {
config = require(configFile);
if (exists) {
config = require(configFile);
extend(session.context, config);
extend(settings, config.settings);
}
Expand All @@ -63,14 +68,12 @@ function extend(obj1, obj2) {
}
}

function startRepl() {
session = repl.start("> ");
session.context.runTests = runTests;
}

// FIXME Hackity, hack, hack. For some reason, this module is not cached. Spying on a copy won't work.
exports.repl = repl;

// Export the settings so they are available in require('jezebel').settings
exports.settings = settings;

exports.runTests = runTests;
exports.fileChanged = fileChanged;
exports.loadConfig = loadConfig;
Expand Down
14 changes: 11 additions & 3 deletions spec/jezebel_spec.js
@@ -1,12 +1,12 @@
describe('jezebel', function() {
var childProcess = require('child_process'),
sys = require('sys');
var watcher, jezebel, repl, session, setings;
var watcher, jezebel, repl, session, settings;

beforeEach(function() {
watcher = require('jezebel/watcher');
jezebel = require('jezebel');
session = {context: {}};
session = {context: {}};
spyOn(jezebel.repl, 'start').andReturn(session);
spyOn(watcher, 'watchFiles');
spyOn(process.stdin, 'emit');
Expand Down Expand Up @@ -62,7 +62,15 @@ describe('jezebel', function() {
});

it('invokes the settings callback to determine the tests to run', function() {
pending();
spyOn(console, 'log');
var settings = require('jezebel').settings
settings.onChange = function() {}
spyOn(settings, 'onChange').andReturn(['spec/foo_spec.js'])
spyOn(childProcess, 'spawn').andReturn(process);
jezebel.fileChanged(__filename, {mtime: new Date(100)}, {mtime: new Date(0)});
expect(settings.onChange).toHaveBeenCalled();
expect(console.log).toHaveBeenCalledWith('Running examples in spec/foo_spec.js');
settings.onChange = null;
});
});

Expand Down

0 comments on commit f945eef

Please sign in to comment.