Quantcast
Channel: Craft It Online!
Viewing all articles
Browse latest Browse all 92

Grunt.js + Symfony2 Big Brother Watches Your PHPSpec Descriptions

$
0
0

Straight to the point!

Drop a couple of files into your Symfony2′s project directory or any php library:

Gruntfile.js

module.exports = function (grunt) {
    grunt.initConfig({
        shell: {
            tests: {
                command: [
                    'clear',
                    'vendor/bin/phpspec run -n --ansi'
                ].join('&&'),
                options: {
                    stdout: true
                }
            }
        },
        watch: {
            tests: {
                files: ['{lib,src,spec}/**/*.php'],
                tasks: ['shell:tests']
            }
        }
    });
 
    // plugins
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-shell');
 
    // tasks
    grunt.registerTask('tests', ['shell:tests', 'watch:tests']);
};

and

package.json

{
    "devDependencies": {
        "grunt": "~0.4.1",
        "grunt-contrib-watch": "~0.5.1",
        "grunt-shell": "~0.3.1",
        "grunt-cli": "~0.1.9"
    }
}

Then proceed to install the dependencies above similar to composer like a pro:

brew install node
npm install

Then for your commodity create a file like:

~ cat ./dev
#!/bin/bash
node_modules/.bin/grunt tests

and simply run:

./dev

And try to change a file in your folders src, lib or spec and you will see the watcher in action.

Now start doing PRs to your favourite repos with these changes and give the reference url if you want :) !

I credit @chadrien for helping me get up to speed with this technique.

You are welcome to say thanks buying http://pilotci.com The Lean Book on Symfony2 Ecommerce !

With the support I will buy a license of keynote to present my talk in Argentina in this conference:

http://www.phpconference.com.ar/schedule/?lang=en

undeservingly thankful, your friend

@cordoval


Viewing all articles
Browse latest Browse all 92

Trending Articles