/*
 * use-test.js: Basic tests for the carapace module
 *
 * (C) 2011 Nodejitsu Inc
 * MIT LICENCE
 *
 */
 
var assert = require('assert'),
    path = require('path'),
    exec = require('child_process').exec,
    http = require('http'),
    request = require('request'),
    vows = require('vows'),
    helper = require('../helper/macros.js'),
    carapace = require('../../lib/carapace');

var PORT = 5050;

var script = path.join(__dirname, '..', '..', 'examples', 'chroot-jail', 'server.js');
    
vows.describe('carapace/spawn/local').addBatch({
  "When using haibu-carapace": helper.assertListen(PORT, {
    "and running `./server.js` with no plugins": helper.assertRun(script, null, {
      "should set the correct exports on carapace._module": function (_, _) {
        assert.equal(carapace._module.exports.port, 1337);
      },
      "should emit the `carapace::port` event": {
        topic: function () {
          carapace.on('carapace::port', this.callback.bind(carapace, null));
        },
        "with the correct port": function (err, info) {
          assert.equal(carapace.event, 'carapace::port');
          assert.equal(info.port, 1337);
        },
        "should correctly start the HTTP server": {
          topic: function () {
            request({ uri: 'http://localhost:' + carapace._module.exports.port }, this.callback);      
          },
          "that responds with a cwd": function (err, res, body) {
            assert.equal(body, process.cwd());
          }
        }
      }
    })
  })
}).export(module);

@@ -389,26 +389,8 @@
 );%0A%0A
-var PORT = 5050;%0A%0A
 var 
@@ -560,34 +560,8 @@
 ce%22:
- helper.assertListen(PORT,
  %7B%0A 
@@ -811,26 +811,16 @@
 it the %60
-carapace::
 port%60 ev
@@ -879,26 +879,16 @@
 ace.on('
-carapace::
 port', t
@@ -1034,18 +1034,8 @@
 t, '
-carapace::
 port
@@ -1443,17 +1443,16 @@
   %7D)%0A  %7D
-)
 %0A%7D).expo

Use new API in `spawn/local-run` test