Permalink
Browse files

Fixing broken tests from pull request; Now works with node.js 0.6.2

  • Loading branch information...
1 parent 4944205 commit d27aabbb58e4b90a2528f66c920496ff09d4d7d7 @benrady committed Jan 31, 2012
Showing with 31 additions and 34 deletions.
  1. +5 −4 .jezebel
  2. +1 −4 bin/jezebel
  3. +2 −2 package.json
  4. +4 −2 spec/jezebel_spec.js
  5. +0 −3 spec/spec_helper.js
  6. +19 −19 spec/watcher_spec.js
View
@@ -24,10 +24,11 @@ exports.settings = {
},
onChange: function(path) {
stats.changes += 1;
- if (path.match(/.*\.js$/)) {
- // load the most recently changed module into the $$ variable in the REPL
- reloadModule(path);
- }
+ // Broken in Node 0.6 :-(
+ //if (path.match(/.*\.js$/)) {
+ // // load the most recently changed module into the $$ variable in the REPL
+ // reloadModule(path);
+ //}
}
};
View
@@ -1,10 +1,7 @@
-#!/usr/bin/env node
+#!/usr/bin/env NODE_PATH=./lib:$NODE_PATH node
var path = require('path'),
fs = require('fs');
-//var binDir = path.dirname(fs.realpathSync(__filename));
-//var lib = path.join(binDir, '../lib');
-//require.paths.push(lib);
var jezebel = require(path.join('../lib', 'jezebel'));
jezebel.run();
View
@@ -12,8 +12,8 @@
"lib": "."
},
"engines": {
- "node": ">=0.4.0"
+ "node": ">=0.6.2"
},
- "dependencies": {"jessie": ">=0.3.1"},
+ "dependencies": {"jessie": ">=0.4.1"},
"bin": {"jezebel": "./bin/jezebel"}
}
View
@@ -13,8 +13,10 @@ describe('jezebel', function() {
spyOn(process.stdin, 'emit');
spyOn(process, 'nextTick');
spyOn(require('path'), 'exists').andCallFake(function(file, callback) {
- expect(file).toEqual(process.cwd() + '/.jezebel');
- callback(true);
+ if(file == process.cwd() + '/.jezebel')
+ callback(true);
+ else
+ callback(false);
});
require(process.cwd() + '/.jezebel').settings = settings = {};
});
View
@@ -1,8 +1,5 @@
var fs = require('fs');
var path = require('path');
-//var binDir = path.dirname(fs.realpathSync(__filename));
-//var lib = path.join(binDir, '../lib');
-//require.paths.push(lib);
jasmine.Spy.prototype.invokeCallback = function(){
var argsToInvokeWith = arguments;
View
@@ -4,7 +4,7 @@ describe('watcher', function() {
beforeEach(function() {
watcher = require('jezebel/watcher');
fs = require('fs');
- spyOn(fs, 'watchFile');
+ spyOn(fs, 'watch');
spyOn(fs, 'unwatchFile');
spyOn(fs, 'stat');
spyOn(fs, 'readdir');
@@ -20,14 +20,14 @@ describe('watcher', function() {
fs.stat.invokeCallback('', {isDirectory : function(){return false;}});
});
- it('provides the correct filename and options to watchFile', function() {
- expect(fs.watchFile.argsForCall[0][0]).toEqual('filename');
- expect(fs.watchFile.argsForCall[0][1]).toEqual({persistent : true, interval : 500});
+ it('provides the correct filename and options to watch', function() {
+ expect(fs.watch.argsForCall[0][0]).toEqual('filename');
+ expect(fs.watch.argsForCall[0][1]).toEqual({persistent : true, interval : 500});
});
- it('curries filename to the callback of watchFile', function() {
- fs.watchFile.invokeCallback('curr', 'prev');
- expect(callback).toHaveBeenCalledWith('filename', 'curr' , 'prev');
+ it('curries filename to the callback of watch', function() {
+ fs.watch.invokeCallback();
+ expect(callback).toHaveBeenCalledWith('filename');
});
});
@@ -37,41 +37,41 @@ describe('watcher', function() {
fs.stat.invokeCallback('', {isDirectory : function(){return true;}});
});
- it('calls watchFile on dir and all files in the dir', function() {
+ it('calls watch on dir and all files in the dir', function() {
fs.readdir.invokeCallback('', ['file0', 'file1']);
fs.stat.invokeCallback('', {isDirectory : function(){return false;}});
- expect(fs.watchFile.callCount).toEqual(3);
- expect(fs.watchFile.argsForCall[0][0]).toEqual('dirName');
- expect(fs.watchFile.argsForCall[1][0]).toEqual('dirName/file0');
- expect(fs.watchFile.argsForCall[2][0]).toEqual('dirName/file1');
+ expect(fs.watch.callCount).toEqual(3);
+ expect(fs.watch.argsForCall[0][0]).toEqual('dirName');
+ expect(fs.watch.argsForCall[1][0]).toEqual('dirName/file0');
+ expect(fs.watch.argsForCall[2][0]).toEqual('dirName/file1');
});
it('detects new files and watches those', function() {
fs.readdir.reset();
- fs.watchFile.invokeCallback('');
+ fs.watch.invokeCallback('');
fs.readdir.invokeCallback('', ['file0']);
fs.stat.invokeCallback('', {isDirectory : function(){return false;}});
- expect(fs.watchFile.callCount).toEqual(1);
- expect(fs.watchFile.argsForCall[0][0]).toEqual('dirName/file0');
+ expect(fs.watch.callCount).toEqual(1);
+ expect(fs.watch.argsForCall[0][0]).toEqual('dirName/file0');
});
});
it('only watches a file once', function() {
watcher.watchFiles('dirName', function() {});
fs.stat.invokeCallback('', {isDirectory : function(){return true;}});
- var dirChanged = fs.watchFile.argsForCall[0][2];
+ var dirChanged = fs.watch.argsForCall[0][2];
fs.readdir.invokeCallback('', ['file0']);
dirChanged();
fs.readdir.invokeCallback('', ['file0']);
fs.stat.invokeCallback('', {isDirectory : function(){return false;}});
- expect(fs.watchFile.callCount).toEqual(2);
- expect(fs.watchFile.argsForCall[0][0]).toEqual('dirName');
- expect(fs.watchFile.argsForCall[1][0]).toEqual('dirName/file0');
+ expect(fs.watch.callCount).toEqual(2);
+ expect(fs.watch.argsForCall[0][0]).toEqual('dirName');
+ expect(fs.watch.argsForCall[1][0]).toEqual('dirName/file0');
});
it('writes errors to sys.error', function() {

0 comments on commit d27aabb

Please sign in to comment.