mikeerickson / gulp-phpspec

gulp-phpspec plugin
MIT License
6 stars 2 forks source link

gulp-phpspec doesn't use correct PHP namespace #26

Closed bgturner closed 8 years ago

bgturner commented 8 years ago

When using a custom php namespace, gulp-phpspec is unable to locate and run the specs.

I've created a namespace called BTCodeKatas -- setting it both in the composer.json file as well as a phpspec.yml file in the project root.

The below configuration allows me to create new specs using the typical phpspec describe Namespace/ClassName as well as run those specs using phpspec run. However when executing gulp there are no specs found.

// composer.json
{
    "require-dev": {
        "phpspec/phpspec": "2.0.*@dev"
    },
    "autoload": {
        "psr-4": {
            "BTCodeKatas\\": "src/"
        }
    }
}
// phpspec.yml
suites:
    btcodekatas:
        namespace: BTCodeKatas
        psr4_prefix: BTCodeKatas
// gulpfile.js
var gulp = require('gulp');
var phpspec = require('gulp-phpspec');

gulp.task('test', function(){
    var phpspecOptions = {
        verbose: 'vv',
        // clear: true,
        formatter: ' pretty',
        debug: true
    };
    gulp.src('spec/**/*.php')
        .pipe(phpspec('', phpspecOptions));
});

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

gulp.task('default', ['test', 'watch']);

image

bgturner commented 8 years ago

I figured out what was wrong with my issue. I had installed a global version of phpspec which was much newer ( 3.1.1 ) vs the 2.0.0 series that was laid out in the composer.json file

Updating the composer.json file to the most recent version fixed this.