
/**
 * Module dependencies.
 */

var stylus = require('stylus'),
    nib = require('../'),
    fs = require('fs');

// test cases

var cases = fs.readdirSync('test/cases').filter(function(file){
  return ~file.indexOf('.styl');
}).map(function(file){
  return file.replace('.styl', '');
});

describe('integration', function(){
  cases.forEach(function(test){
    var name = test.replace(/[-.]/g, ' ');
    it(name, function(){
      var path = 'test/cases/' + test + '.styl';
      var styl = fs.readFileSync(path, 'utf8').replace(/\r/g, '');
      var css = fs.readFileSync('test/cases/' + test + '.css', 'utf8').replace(/\r/g, '').trim();

      var style = stylus(styl)
        .use(nib())
        .set('filename', path)
        .define('url', stylus.url());

      if (~test.indexOf('compress')) style.set('compress', true);

      style.render(function(err, actual){
        if (err) throw err;
        actual.trim().should.equal(css);
      });
    });
  });
});

@@ -1,9 +1,8 @@
-%0A
 /**%0A * M
@@ -25,17 +25,16 @@
 es.%0A */%0A
-%0A
 var styl
@@ -113,21 +113,156 @@
 ;%0A%0A/
-/ test cases%0A
+**%0A * Read test/cases directory and filter all %60.styl%60 files, then remove%0A * this extension for each file in the collection and prepare to test.%0A */
 %0Avar
@@ -354,16 +354,59 @@
 .styl');
+ // bitwise flip to treat result as truthy.
 %0A%7D).map(
@@ -462,16 +462,144 @@
 );%0A%7D);%0A%0A
+/*%0A * For each %60.styl%60 and %60.css%60 pair in %60test/cases%60, compile stylus to css%0A * and compare actual result to expected css.%0A */%0A
 describe

improve comments for test runner