forked from vgamula/gulp-cucumber
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
40 lines (37 loc) · 1.12 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var gulp = require('gulp');
var cucumber = require('./');
var spawn = require('child_process').spawn;
var expect = require('chai').expect;
gulp.task('cucumber', function() {
return gulp.src('features/*').pipe(cucumber({
'steps': 'features/step_definitions/*_steps.js',
'support': 'features/support/*.js',
'format': 'summary'
})).once('end', function() {
console.log('stream end!!');
});
});
gulp.task('test', function(callback) {
var p = spawn('gulp', ['cucumber']);
var chunks = [];
p.stderr.pipe(process.stderr);
p.stdout.pipe(process.stdout);
p.stdout.setEncoding('utf8');
p.stdout.on('data', function(chunk) {
chunks.push(chunk);
});
p.on('close', function(status) {
try {
if (status !== 0) {
throw new Error('gulp cucumber exited: ' + status);
} else {
var text = chunks.join('');
expect(text).to.match(/meow!!/);
expect(text).to.match(/stream end!!/);
}
callback();
} catch (e) {
callback(e);
}
})
});