Skip to content

Instantly share code, notes, and snippets.

@pgchamberlin
Created April 14, 2014 09:53
Show Gist options
  • Save pgchamberlin/10633516 to your computer and use it in GitHub Desktop.
Save pgchamberlin/10633516 to your computer and use it in GitHub Desktop.
Jasmine data provider helper
//Data provider functionality in jasmine
//see http://blog.jphpsf.com/2012/08/30/drying-up-your-javascript-jasmine-tests
function using(name, values, func){
for (var i = 0, count = values.length; i < count; i++) {
if (Object.prototype.toString.call(values[i]) !== '[object Array]') {
values[i] = [values[i]];
}
func.apply(this, values[i]);
jasmine.currentEnv_.currentSpec.description += ' (with "' + name + '" using ' + values[i].join(', ') + ')';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment