Perhaps a little simpler than what you have above (though perhaps you want 
the additional layer, I'm not sure) is to put your tests in a loop, like:

var fruits = [{'name': 'apple', 'juicy': true}, {'name': 'orange', 'juicy': 
true}];
fruits.forEach(function(fruit) {
  describe(fruit.name, function() {
    it('should be juicy', function() {
      assert(fruit.juicy);
  });
});

I'll often use this pattern when I have a bunch of very similar tests -- 
often with arrays of inputs and expected outputs, like this:

var test_data = [
  [3, 4, 7],
  [7, 8, 15],
  [2, 1, 3]
];
describe('addition', function() {
  test_data.forEach(function(d) {
    it('should add ' + d[0] + ' + ' + d[1] + ' to equal ' + d[2], 
function() {
      assert.equal(d[0] + d[1], d[2]);
    });
  });
});

On Thursday, May 16, 2013 9:43:34 PM UTC-7, Sam Roberts wrote:
>
> I'll check that out, thanks. 
>
> Right now I'm doing something like: 
>
> function describeFruit(type) { 
>    describe("fruit of "+type.name, function() { 
>       it("should be juicy", function() { 
>          assert(type.juicy); 
> });});} 
>
> describeFruit("apple"); 
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to