/*!
 * data-driven
 * Copyright(c) 2013 Fluent Software Solutions Ltd <info@fluentsoftware.co.uk>
 * MIT Licensed
 */

 module.exports = function(data, fn) {
    var mochaIt = it
    
    data.forEach(function(testData) {
        try {
            it = function(title, f) {
                
                for (var key in testData) {
                    title = title.replace('{'+key+'}',testData[key])
                }

                var testFn = f.length < 2 ? 
                    function() {
                        f(testData)
                    } : 
                    function(done) {
                        f(testData,done)
                    }
                    
                mochaIt(title, testFn)
            }

            fn()
        } finally {
            it = mochaIt
        }
    })
}
/*!
 * data-driven
 * Copyright(c) 2013 Fluent Software Solutions Ltd <info@fluentsoftware.co.uk>
 * MIT Licensed
 */

 module.exports = function(data, fn) {
    var mochaIt = it
    var mochaBefore = before

    data.forEach(function(testData) {
        try {
            it = function(title, f) {
                for (var key in testData) {
                    title = title.replace('{'+key+'}',testData[key])
                }

                if (f !== undefined) {
                    var testFn = f.length < 2 ?
                        function() {
                            f(testData)
                        } :
                        function(done) {
                            f(testData,done)
                        }
		}

                mochaIt(title, testFn)
            }

            before = function(f) {
                var testFn = f.length < 2 ?
                    function() {
                        f(testData)
                    } :
                    function(done) {
                        f(testData,done)
                    }

                mochaBefore(testFn)
            }

            fn()
        } finally {
            it = mochaIt
	    before = mochaBefore
        }
    })
}

Add support for pending, undefined it() tests and for data-driving Mocha's before()