Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

require.paths removed #14

Merged
merged 1 commit into from

5 participants

@rodzyn

Fixing require.path issues in node 0.5.x and higher (maybe it could be done better, but it works...)

@raoulmillais

Nice. +1 for this. require.paths has been deprecated for a while now and maintaining a separate fork isn't ideal.

@sublimino

+1 Thanks for the patch!

@DavidArno

(updated as part of the problem was due to my ignorance over the need to use --global with npm on Windows to install it correctly)

Hi,

I'm not sure if the problem I'm having is due to the change you have made, or whether jessie isn't really designed for use with Windows.

I installed jessie with node 0.6 on Windows by installing from this fork. However, I can only get it to work with .js specs, not with coffeescript. For example,

describe("Simple test", function() {
it("should work", function() {
expect (1+1).toEqual(2);
});
it("should fail", function() {
expect (1+1).toEqual(3);
});
});

works as expected and results in:

.F

Failures:

1) Simple test should fail.
Expected 2 to equal 3.
# at [object Object]. (c:\development\coffee\projects\GameOfLife\specs\really_basic_spec.js:6:22)

Completed in 0.035 seconds
2 examples, 1 failure

However, the equivalent coffeescript spec:

describe "Simple test", ->
it "should work", ->
expect (1+1).toEqual(2)
it "should fail", ->
expect (1+1).toEqual(3)

results in the following error:
...\specs\really_basic_spec.coffee:1
cribe "Simple te
^^^^^^^^^^^^^
Jessie failed to start. Here's some info about the problem:
SyntaxError: Unexpected string
at Module._compile (module.js:427:25)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at C:\Users\david\AppData\Roaming\jessie\lib\jessie\runner.js:11:36
at Array.forEach (native)
at [object Object].run (C:\Users\david\AppData\Roaming\jessie\lib\jessie\runner.js:11:11)
at Object.run (C:\Users\david\AppData\Roaming\jessie\lib\jessie.js:11:47)

As node,js didn't work well on Windows prior to 0.6 and as 0.5 broke previous version of jessie, I cannot test this in other configurations. Hopefully there's sufficient info here though to enable you to tell me whether this pull request breaks coffeescript or if there is another problem.

@marcinbunsch marcinbunsch merged commit 30d9163 into futuresimple:master
@marcinbunsch

Merging it in, will push it out ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2011
  1. require.paths is removed (since node 0.5.x)

    Marcin Olichwirowicz authored
This page is out of date. Refresh to see the latest.
View
15 bin/jessie
@@ -1,16 +1,9 @@
#!/usr/bin/env node
// Load jessie
-var path = require('path');
-var sys = require('sys');
-var fs = require('fs');
-var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
-require.paths.push(lib)
-require.paths.push(process.cwd() + '/spec')
-
-var jessie = require(path.join(lib, 'jessie'));
+var jessie = require('../lib/jessie');
// Load package.json
-var pkgsrc = fs.readFileSync(__dirname + '/../package.json');
+var pkgsrc = require('fs').readFileSync(__dirname + '/../package.json');
var pkg = JSON.parse(pkgsrc)
// Enable cli and set version name based on package.json
@@ -24,7 +17,7 @@ cli.parse({
}, null);
process.on('uncaughtException', function (err) {
- var ansi = require('jessie/ansi')
+ var ansi = require('../lib/jessie/ansi')
console.log(ansi.red + "Jessie failed to start. Here's some info about the problem:"+ansi.none)
console.log(err.stack);
});
@@ -32,7 +25,7 @@ process.on('uncaughtException', function (err) {
// Main loop
cli.main(function(args, options) {
if (args.length == 0) {
- sys.puts(cli.getUsage())
+ require('util').puts(cli.getUsage())
process.exit(1)
}
jessie.run(args, options, function(fail) {
View
6 lib/jessie.js
@@ -1,6 +1,6 @@
-require('jessie/jasmine')
-exports.sugar = require('jessie/sugar').sugar
-exports.runner = require('jessie/runner').runner
+require('./jessie/jasmine')
+exports.sugar = require('./jessie/sugar').sugar
+exports.runner = require('./jessie/runner').runner
exports.include = function(filename) {
var src = require('fs').readFileSync(filename + '.js');
View
4 lib/jessie/formatters/nested.js
@@ -1,6 +1,6 @@
-var sys = require('sys')
+var sys = require('util')
var fs = require('fs')
-var ansi = require('jessie/ansi')
+var ansi = require('../ansi')
exports.formatter = {
start: function() {
View
4 lib/jessie/formatters/progress.js
@@ -1,6 +1,6 @@
-var sys = require('sys')
+var sys = require('util')
var fs = require('fs')
-var ansi = require('jessie/ansi')
+var ansi = require('../ansi')
exports.formatter = {
spec: function(result, spec) {
View
2  lib/jessie/formatters/xunit.js
@@ -1,4 +1,4 @@
-var sys = require('sys');
+var sys = require('util');
exports.formatter = {
specStart: function(spec) {
View
8 lib/jessie/reporter.js
@@ -1,15 +1,15 @@
var fs = require('fs');
-var sys = require('sys')
-var ansi = require('jessie/ansi')
+var sys = require('util')
+var ansi = require('./ansi')
exports.reporter = function(format, callback) {
format = format || 'progress'
this.callback = callback
try {
- this.formatter = require('jessie/formatters/' + format).formatter
+ this.formatter = require('./formatters/' + format).formatter
} catch(e) {
sys.puts(ansi.red + "Failed to load " + format + " formatter. Defaulting to progress formatter" + ansi.none)
- this.formatter = require('jessie/formatters/progress').formatter
+ this.formatter = require('./formatters/progress').formatter
}
var formatter = this.formatter
this.formatter.reporter = this;
View
4 lib/jessie/runner.js
@@ -1,7 +1,7 @@
exports.runner = function(args, options, callback) {
this.jasmine = jasmine.getEnv();
- this.finder = new (require('jessie/finder')).finder(),
- this.reporter = new (require('jessie/reporter')).reporter(options.format, callback)
+ this.finder = new (require('./finder')).finder(),
+ this.reporter = new (require('./reporter')).reporter(options.format, callback)
this.run = function() {
var specs = this.finder.find(args, process.cwd())
var runner = this;
View
2  spec/helpers/stdout.js
@@ -1,5 +1,5 @@
var StdoutCapture = function() {
- var sys = require('sys')
+ var sys = require('util')
var originals = {
puts: sys.puts,
print: sys.print
View
2  spec/jessie/ansi_spec.js
@@ -1,6 +1,6 @@
describe('jessie.ansi', function() {
- var ansi = require('jessie/ansi')
+ var ansi = require('../../lib/jessie/ansi')
it('should have proper red', function() {
ansi.red.should_match(/\033\[31m/)
View
2  spec/jessie/finder_spec.js
@@ -1,6 +1,6 @@
describe('jessie.finder', function() {
var path = require('path');
- var finder = new (require('jessie/finder').finder)()
+ var finder = new (require('../../lib/jessie/finder').finder)()
it("should find files if only dir is specified", function() {
finder.find(['spec']).length.should_be(13)
View
26 spec/jessie/formatters/nested_spec.js
@@ -1,12 +1,12 @@
describe('formatters', function() {
- var reporter = new (require('jessie/reporter')).reporter('nested')
+ var reporter = new (require('../../../lib/jessie/reporter')).reporter('nested')
describe('nested formatter', function() {
describe('single spec', function() {
it("should use the green spec description to render a successful spec", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.spec({fail: false}, {description: 'my spec'})
})
capture.output().should_match('my spec')
@@ -15,7 +15,7 @@ describe('formatters', function() {
it("should use the red spec description to render a failing spec", function() {
var original_depth = reporter.formatter.depth
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.spec({fail: true}, {description: 'my spec'})
})
capture.output().should_match('my spec')
@@ -25,7 +25,7 @@ describe('formatters', function() {
it("should use the yellow spec description to render a pending spec", function() {
var original_depth = reporter.formatter.depth
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.spec({pending: true}, {description: 'my spec'})
})
capture.output().should_match('my spec')
@@ -36,13 +36,13 @@ describe('formatters', function() {
it("should render the spec with appropriate spacing on the left", function() {
var original_depth = reporter.formatter.depth
reporter.formatter.depth = 1
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.specStart({description: 'my spec'})
reporter.formatter.spec({fail: true}, {description: 'my spec'})
})
capture.output().should_match(/^ {2}/)
reporter.formatter.depth = 2
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.specStart({description: 'my spec'})
reporter.formatter.spec({fail: true}, {description: 'my spec'})
})
@@ -57,7 +57,7 @@ describe('formatters', function() {
it("should render the suite name", function() {
var original_depth = reporter.formatter.depth
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.suiteStart({description: 'my suite'})
})
capture.output().should_match('my suite')
@@ -69,7 +69,7 @@ describe('formatters', function() {
var original_depth = reporter.formatter.depth
reporter.formatter.depth = 1
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.suiteStart({description: 'my suite'})
})
@@ -80,7 +80,7 @@ describe('formatters', function() {
reporter.formatter.depth.should_be(1)
reporter.formatter.depth = 2
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.suiteStart({description: 'my suite'})
})
capture.output().should_match(/^ {4}/)
@@ -94,7 +94,7 @@ describe('formatters', function() {
reporter.formatter.depth = 1
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.suiteStart({description: 'my suite'})
})
@@ -125,7 +125,7 @@ describe('formatters', function() {
}]
it("should properly render a summary", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.finish(result)
})
@@ -146,7 +146,7 @@ describe('formatters', function() {
stacktrace: ['Expected A to be B', 'file.js:23:2', 'another_file.js:30:11']
}]
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.finish(result)
})
@@ -167,7 +167,7 @@ describe('formatters', function() {
stacktrace: ['Expected A to be B', 'file.js:23:2', 'another_file.js:30:11']
}]
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.finish(result)
})
View
14 spec/jessie/formatters/progress_spec.js
@@ -1,12 +1,12 @@
describe('formatters', function() {
- var reporter = new (require('jessie/reporter')).reporter('progress')
+ var reporter = new (require('../../../lib/jessie/reporter')).reporter('progress')
describe('progress formatter', function() {
describe('single spec', function() {
it("should use a dot to render a successful spec", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.spec({fail: false})
})
capture.output().should_match('.')
@@ -14,7 +14,7 @@ describe('formatters', function() {
})
it("should use a star to render a pending spec", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.spec({pending: true})
})
capture.output().should_match(/\*/)
@@ -22,7 +22,7 @@ describe('formatters', function() {
})
it("should use a F to render a failed spec", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.spec({fail: true})
})
capture.output().should_match('F')
@@ -40,7 +40,7 @@ describe('formatters', function() {
}]
it("should properly render a summary", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.finish(result)
})
@@ -61,7 +61,7 @@ describe('formatters', function() {
stacktrace: ['Expected A to be B', 'file.js:23:2', 'another_file.js:30:11']
}]
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.finish(result)
})
@@ -82,7 +82,7 @@ describe('formatters', function() {
stacktrace: ['Expected A to be B', 'file.js:23:2', 'another_file.js:30:11']
}]
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
reporter.formatter.finish(result)
})
View
12 spec/jessie/formatters/xunit_spec.js
@@ -10,7 +10,7 @@ function specsAsArray(output) {
}
describe('XUnit formatter', function() {
- var formatter = new (require('jessie/reporter')).reporter('xunit').formatter
+ var formatter = new (require('../../../lib/jessie/reporter')).reporter('xunit').formatter
var knownResults;
var emptyRunner;
@@ -41,7 +41,7 @@ describe('XUnit formatter', function() {
});
it('should add an open testsuite tag with the summary in the first position of the output buffer', function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
formatter.finish(knownResults, emptyRunner);
});
var tag = outputAsArray(capture.output())[0];
@@ -56,7 +56,7 @@ describe('XUnit formatter', function() {
});
it('should have the last tag as a close testsuite tag', function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
formatter.finish(knownResults, emptyRunner);
});
var output = outputAsArray(capture.output());
@@ -65,7 +65,7 @@ describe('XUnit formatter', function() {
});
it('should add an open tastcase tag with the summary to the output buffer for successful specs', function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
formatter.finish(knownResults, runnerWithOneSpec);
});
var tag = specsAsArray(capture.output())[0];
@@ -78,7 +78,7 @@ describe('XUnit formatter', function() {
it('should add the reasons of a pended spec to the output buffer', function() {
runnerWithOneSpec.suites()[0].specs()[0].results().getItems()[0].pending = true;
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
formatter.finish(knownResults, runnerWithOneSpec);
});
var tag = specsAsArray(capture.output())[0];
@@ -89,7 +89,7 @@ describe('XUnit formatter', function() {
it('should add the reasons of a failed spec to the output buffer', function() {
runnerWithOneSpec.suites()[0].specs()[0].results().failedCount = 1;
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../../helpers/stdout').capture(function() {
formatter.finish(knownResults, runnerWithOneSpec);
});
var tag = specsAsArray(capture.output())[0];
View
16 spec/jessie/reporter_spec.js
@@ -1,5 +1,5 @@
describe('jessie.reporter', function() {
- var reporter = new (require('jessie/reporter')).reporter('progress')
+ var reporter = new (require('../../lib/jessie/reporter')).reporter('progress')
it("should load formatter", function() {
expect(reporter.formatter.constructor).toEqual(Object)
@@ -18,7 +18,7 @@ describe('jessie.reporter', function() {
describe('#printSummary', function() {
it("should print a summary of a good run", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.printSummary({duration: 12, failed: 0, total: 2})
})
capture.output().should_match('2 examples')
@@ -27,7 +27,7 @@ describe('jessie.reporter', function() {
})
it("should print a summary a failed run", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.printSummary({duration: 15, failed: 1, total: 2})
})
capture.output().should_match(/\033\[31m/) // red
@@ -36,7 +36,7 @@ describe('jessie.reporter', function() {
})
it("should print a summary a pending and failed run", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.printSummary({duration: 15, failed: 1, total: 3, pending: 1})
})
capture.output().should_match(/\033\[31m/) // red
@@ -45,7 +45,7 @@ describe('jessie.reporter', function() {
})
it("should print a summary of a pending", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.printSummary({duration: 15, total: 3, pending: 1})
})
capture.output().should_match(/\033\[33m/) // yellow
@@ -58,7 +58,7 @@ describe('jessie.reporter', function() {
describe('#extractFailureLine', function() {
it("should extract a line from a stacktrace line", function() {
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.extractFailureLine('./spec/jessie/reporter_spec.js:1:1')
})
capture.output().should_match(/describe\(\'jessie.reporter\', function\(\) \{/)
@@ -75,7 +75,7 @@ describe('jessie.reporter', function() {
stacktrace: ['Expected A to be B', 'file.js:23:2', 'another_file.js:30:11']
}]
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.printFailures(failures)
})
@@ -96,7 +96,7 @@ describe('jessie.reporter', function() {
stacktrace: ['Expected A to be B', 'file.js:23:2', 'another_file.js:30:11']
}]
- capture = require('helpers/stdout').capture(function() {
+ capture = require('../helpers/stdout').capture(function() {
reporter.printPendings(failures)
})
View
2  spec/jessie/runner_spec.js
@@ -1,6 +1,6 @@
describe('jessie.runner', function() {
- var runner = new (require('jessie/runner')).runner([''], {})
+ var runner = new (require('../../lib/jessie/runner')).runner([''], {})
it("should load finder", function() {
expect(runner.finder).toBeDefined()
View
2  spec/spec_helper.js
@@ -1,4 +1,4 @@
-var jessie = require('jessie')
+var jessie = require('../lib/jessie')
jessie.sugar()
require('coffee-script');
Something went wrong with that request. Please try again.