Permalink
Browse files

Fixed error classes (missing name which affects instanceof).

  • Loading branch information...
1 parent 8abc6a1 commit fa2e1bcdf669869907769db34c74fd0e77712e9f @jakubpawlowicz committed Jun 17, 2012
Showing with 18 additions and 6 deletions.
  1. +3 −3 lib/assets.js
  2. +15 −3 test/assets-test.js
View
@@ -137,7 +137,7 @@ AssetsExpander.YamlSyntaxError = function(message) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
- this.name = this.constructor.name;
+ this.name = 'YamlSyntaxError';
this.message = message;
};
AssetsExpander.YamlSyntaxError.prototype.__proto__ = Error.prototype;
@@ -146,7 +146,7 @@ AssetsExpander.UnknownGroupError = function(message) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
- this.name = this.constructor.name;
+ this.name = 'UnknownGroupError';
this.message = message;
};
AssetsExpander.UnknownGroupError.prototype.__proto__ = Error.prototype;
@@ -155,7 +155,7 @@ AssetsExpander.UnknownTypeError = function(message) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
- this.name = this.constructor.name;
+ this.name = 'UnknownTypeError';
this.message = message;
};
AssetsExpander.UnknownTypeError.prototype.__proto__ = Error.prototype;
View
@@ -28,7 +28,11 @@ exports.yamlSuite = vows.describe('incorrect yaml').addBatch({
'should give YAML error': function(topic) {
assert.throws(function() {
expanderFor(topic);
- }, AssetsExpander.YamlSyntaxError);
+ }, function(err) {
+ if ((err instanceof AssetsExpander.YamlSyntaxError) && err.name == 'YamlSyntaxError' && /dedented/.test(err.message)) {
+ return true;
+ }
+ });
}
}
});
@@ -151,14 +155,22 @@ exports.groupsSuite = vows.describe('expanding assets groups').addBatch({
'should not fail': function(expanded) {
assert.throws(function() {
expanderFor('assets.yml').processGroup('unknown', 'type1', { type: 'css' });
- }, AssetsExpander.UnknownTypeError);
+ }, function(err) {
+ if ((err instanceof AssetsExpander.UnknownTypeError) && err.name == 'UnknownTypeError' && /unknown/.test(err.message)) {
+ return true;
+ }
+ });
}
},
'expand unknown group': {
'should not fail': function(expanded) {
assert.throws(function() {
expanderFor('assets.yml').processGroup('stylesheets', 'type1', { type: 'css' });
- }, AssetsExpander.UnknownGroupError);
+ }, function(err) {
+ if ((err instanceof AssetsExpander.UnknownGroupError) && err.name == 'UnknownGroupError' && /stylesheets/.test(err.message) && /type1/.test(err.message)) {
+ return true;
+ }
+ });
}
},
'expanding group #1 from assets.yml': {

0 comments on commit fa2e1bc

Please sign in to comment.