Skip to content
Browse files

Implemented pending spec, exported jezebel settings

  • Loading branch information...
1 parent 8083779 commit f945eefd874450bd81d152d23f3e76d1001d8027 Marcin Bunsch committed
Showing with 23 additions and 12 deletions.
  1. +12 −9 lib/jezebel.js
  2. +11 −3 spec/jezebel_spec.js
View
21 lib/jezebel.js
@@ -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));
}
@@ -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) {
@@ -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 {
@@ -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);
}
@@ -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;
View
14 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');
@@ -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;
});
});

0 comments on commit f945eef

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