diff --git a/lib/protos.js b/lib/protos.js index c339c47..3dad067 100644 --- a/lib/protos.js +++ b/lib/protos.js @@ -304,7 +304,8 @@ exports.locals = function(locals) { * @api public */ -exports.ready = function() { +exports.ready = function(err) { + if (err) return this.debug('error loading "%s" error="%s"', this.name, err); this.emit('ready'); }; diff --git a/test/index.test.js b/test/index.test.js index 44d93d0..fd310ac 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -633,4 +633,28 @@ describe('integration', function() { assert(window.onload === onload); }); }); + + describe('#ready', function() { + beforeEach(function() { + integration = new Integration(); + }); + + it('should should emit a ready event', function() { + var called = false; + integration.on('ready', function() { + called = true; + }); + integration.ready(); + assert(called === true); + }); + + it('should should not emit a ready event if the integration fails', function() { + var called = false; + integration.on('ready', function() { + called = true; + }); + integration.ready(new Error('failed to load')); + assert(called === false); + }); + }); });