Skip to content

Commit

Permalink
test - allow the test helper to setup specific config per test
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed Feb 15, 2012
1 parent e9a959e commit 2addd29
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions test/helpers/index.js
@@ -1,14 +1,24 @@

var helpers = exports,
fs = require('fs'),
path = require('path'),
grunt = require('grunt'),
EventEmitter = require('events').EventEmitter;

helpers.task = function task(t) { return function() {
var em = new EventEmitter;
grunt.tasks([t || 'default'], {
tasks: [path.join(__dirname, '../../tasks')],
base: path.join(__dirname, '../fixtures')
}, em.emit.bind(em, 'success'));
return em;
}}
helpers.task = function task(t, options) {
if(options) fs.writeFileSync(path.join(__dirname, '../fixtures/h5bp/grunt.js'), [
'config.init(',
JSON.stringify(options, null , 2),
');'
].join('\n'));

return function() {
var em = new EventEmitter;
grunt.tasks([t || 'default'], {
config: options ? path.join(__dirname, '../fixtures/h5bp/grunt.js') : 'grunt.js',
tasks: [path.join(__dirname, '../../tasks')],
base: path.join(__dirname, '../fixtures/h5bp')
}, em.emit.bind(em, 'success'));
return em;
}
}

0 comments on commit 2addd29

Please sign in to comment.