From 6e17371ee741cf410300f02728c4d4fc3fff070d Mon Sep 17 00:00:00 2001 From: "samuel.gabel" Date: Wed, 30 Oct 2013 15:07:28 +0100 Subject: [PATCH] Add title replacement for describe functions as well --- index.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index df084c4..706692e 100644 --- a/index.js +++ b/index.js @@ -6,15 +6,19 @@ module.exports = function(data, fn) { var mochaIt = it + var mochaDescribe = describe data.forEach(function(testData) { + function replaceVariables(title) { + for (var key in testData) { + title = title.replace('{'+key+'}',testData[key]) + } + return title; + } + try { it = function(title, f) { - for (var key in testData) { - title = title.replace('{'+key+'}',testData[key]) - } - var testFn = f.length < 2 ? function() { f(testData) @@ -23,12 +27,18 @@ f(testData,done) } - mochaIt(title, testFn) + mochaIt(replaceVariables(title), testFn) + } + + describe = function(title, f) { + + mochaDescribe(replaceVariables(title), f) } fn() } finally { it = mochaIt + describe = mochaDescribe } }) -} \ No newline at end of file +}