Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[test] Simplify logic in vows macros

  • Loading branch information...
commit a2a96faab6f420fb09dd01547d9167f8476de6c8 1 parent 27a69fa
@indexzero indexzero authored
View
25 test/helper/macros.js
@@ -31,42 +31,27 @@ macros.assertListen = function (port, vows) {
};
macros.assertUse = function (plugins, vows) {
- var names = typeof plugins === 'string'
- ? path.basename(plugins, '.js')
- : plugins.map(function (p) { return path.basename(p, '.js') });
+ var names = plugins.map(function (p) { return path.basename(p, '.js') });
var context = {
topic: function () {
- if (typeof plugins === 'string') {
- console.dir(plugins);
- carapace.load(plugins);
- carapace.use(carapace.plugins[names], this.callback.bind(this, null));
- return undefined;
- }
-
//
// should be an array
// we have to do this because carapace, preloads these plugins
//
- var pg = plugins.map(function (plugin) {
+ var scripts = plugins.map(function (plugin) {
return carapace.load(plugin);
});
- carapace.use(pg, this.callback.bind(null, null));
+ carapace.use(scripts, this.callback.bind(null, null));
},
"should have load the plugin(s)": function () {
- if (typeof plugins === 'string') {
- assert.isString(names);
- assert.isFunction(carapace[names]);
- return;
- }
-
assert.isArray(plugins);
- plugins.forEach(function (plugin) {
+ names.forEach(function (name) {
//
// Remark (drjackal): Hopefully nothing malicious in plugins...
//
- assert.isFunction(carapace[plugin]);
+ assert.isFunction(carapace[name]);
});
}
};
View
4 test/simple/use-custom-plugin-test.js
@@ -16,8 +16,8 @@ var PORT = 5050;
vows.describe('carapace/simple/use-custom-plugin').addBatch({
"When using haibu-carapace": helper.assertListen(PORT, {
"a custom plugin" : {
- //"with an absolute path": helper.assertUse(path.join(__dirname, '..', 'fixtures', 'custom.js')),
- "with a relative path": helper.assertUse('../fixtures/relative.js')
+ "with an absolute path": helper.assertUse([path.join(__dirname, '..', 'fixtures', 'custom.js')]),
+ //"with a relative path": helper.assertUse('../fixtures/relative.js')
}
})
}).export(module);
View
2  test/simple/use-load-test.js
@@ -15,7 +15,7 @@ var PORT = 5050;
vows.describe('carapace/simple/use').addBatch({
"When using haibu-carapace": helper.assertListen(PORT, {
- "use chdir plugins" : helper.assertUse('chdir', {
+ "use chdir plugins" : helper.assertUse(['chdir'], {
"and use chroot and heartbeat" : helper.assertUse(['chroot', 'heartbeat'])
})
})
Please sign in to comment.
Something went wrong with that request. Please try again.