Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHPSpec auto-testing Gulpfile
var gulp = require('gulp');
var phpspec = require('gulp-phpspec');
var run = require('gulp-run');
var notify = require('gulp-notify');
gulp.task('test', function() {
gulp.src('spec/**/*.php')
.pipe(run('clear'))
.pipe(phpspec('', { notify: true }))
.on('error', notify.onError({
title: 'Dangit',
message: 'Your tests failed!',
icon: __dirname + '/fail.png'
}))
.pipe(notify({
title: 'Success',
message: 'All tests have returned green!'
}));
});
gulp.task('watch', function() {
gulp.watch(['spec/**/*.php', 'src/**/*.php'], ['test']);
});
gulp.task('default', ['test', 'watch']);
@carnar

This comment has been minimized.

Copy link

commented Sep 19, 2014

I had to change line 8 for this:
.pipe(run('clear').exec())

@frcaliga

This comment has been minimized.

Copy link

commented Sep 24, 2014

I had to change line 8 for this:
.pipe(shell('clear'))
and conseguntely
insert the following line
var shell = require('gulp-shell');

@jfmercer

This comment has been minimized.

Copy link

commented May 2, 2015

Like @carnar I too had to change line 8 to .pipe(run('clear').exec())

@mishbah

This comment has been minimized.

Copy link

commented Aug 21, 2015

@anthonywallen

This comment has been minimized.

Copy link

commented Jan 6, 2017

Yes I had to change line 8 as well .pipe(run('clear').exec()).

@iwasherefirst2

This comment has been minimized.

Copy link

commented Nov 25, 2018

THis does not work anymore with Gulp4

@4unkur

This comment has been minimized.

Copy link

commented Mar 13, 2019

@cmancre

This comment has been minimized.

Copy link

commented Jun 27, 2019

Gulp 4

var gulp = require('gulp');
var phpspec = require('gulp-phpspec');
var run = require('gulp-run');
var notify = require('gulp-notify');

gulp.task('test', function(done){
	gulp.src('spec/**/*.php')
		.pipe(run('clear').exec())
		.pipe(phpspec('', {notify:true}))
		.on('error', notify.onError({
			'title': 'Failed!!!',
			'message': 'Your test failed'
			//'icon': __dirname + '/fail.png',
		}))
		.pipe(notify({
			'title': 'Success',
			'message': 'All tests have returned green'
		}));
	done();
});

gulp.task('watch', function(){
	gulp.watch(['spec/**/*.php', 'src/**/*.php'], gulp.series(['test']));
});

gulp.task('default', gulp.series(['test','watch']));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.