Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

if (Collections.findOne({name})) {
  Collections.update({name}, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return True;
  },
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root

Response:
if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Response:
collection.find().observe
      added: (document) -> Collections.update {name}, {$inc: {count: 1}}
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count()}
    else
      Collections.insert {name, count: collection.find().count()}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) -> Collections.update {name}, {$inc: {count: 1}}
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count()}
    else
      Collections.insert {name, count: collection.find().count()}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e
```

Response:
var save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

if (Collections.findOne({name})) {
  Collections.update({name}, {
    $set: {
      count: collection.find().count()
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count()
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return True;
  },
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

if (Collections.findOne({name})) {
  Collections.update({name}, {
    $set: {
      count: collection.find().count()
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count()
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return True;
  },
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});
```

Response:
collection.find().observe
      added: (document) -> Collections.update {name}, {$inc: {count: 1}}
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count()}
    else
      Collections.insert {name, count: collection.find().count()}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
collection.find().observe
      added: (document) -> Collections.update {name}, {$inc: {count: 1}}
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count()}
    else
      Collections.insert {name, count: collection.find().count()}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value

Response:
console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Response:
publish_to_admin_with_pagination = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
publish_to_admin_with_pagination = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var publish_to_admin_with_pagination;

publish_to_admin_with_pagination = function(name, publish_func) {
  return Meteor.publish(name, function() {
    if (Meteor.users.findOne({
      _id: this.userId,
      'profile.admin': true
    })) {
      return publish_func();
    }
  });
};

// publish our own internal state
Meteor.publish("admin", function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Collections.find();
  }
});

Meteor.publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var publish_to_admin_with_pagination;

publish_to_admin_with_pagination = function(name, publish_func) {
  return Meteor.publish(name, function() {
    if (Meteor.users.findOne({
      _id: this.userId,
      'profile.admin': true
    })) {
      return publish_func();
    }
  });
};

// publish our own internal state
Meteor.publish("admin", function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Collections.find();
  }
});

Meteor.publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
publish_to_admin_with_pagination = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
publish_to_admin_with_pagination = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state

Response:
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe 'GET /devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe 'GET /devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()
```

Response:
var MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;

_ = require('lodash');

path = require('path');

url = require('url');

MeshbluHTTP = require('meshblu-http');

MeshbluConfig = require('meshblu-config');

meshblu = require('meshblu');

request = require('request');

describe('REST', function() {
  before(function(done) {
    var filename;
    filename = path.join(__dirname, 'meshblu.json');
    this.config = new MeshbluConfig({
      filename: filename
    }).toJSON();
    this.meshblu = new MeshbluHTTP(this.config);
    this.conx = meshblu.createConnection({
      server: this.config.server,
      port: this.config.port,
      uuid: this.config.uuid,
      token: this.config.token
    });
    this.conx.on('ready', () => {
      return done();
    });
    return this.conx.on('notReady', done);
  });
  it('should get here', function() {
    return expect(true).to.be.true;
  });
  return describe('GET /devices', function() {
    describe('when called with a valid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({}, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices" message', function() {
        expect(this.message.topic).to.deep.equal('devices');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          request: {}
        });
      });
    });
    return describe('when called with an invalid request', function() {
      return beforeEach(function(done) {
        return this.meshblu.devices({
          uuid: 'invalid-uuid'
        }, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;

_ = require('lodash');

path = require('path');

url = require('url');

MeshbluHTTP = require('meshblu-http');

MeshbluConfig = require('meshblu-config');

meshblu = require('meshblu');

request = require('request');

describe('REST', function() {
  before(function(done) {
    var filename;
    filename = path.join(__dirname, 'meshblu.json');
    this.config = new MeshbluConfig({
      filename: filename
    }).toJSON();
    this.meshblu = new MeshbluHTTP(this.config);
    this.conx = meshblu.createConnection({
      server: this.config.server,
      port: this.config.port,
      uuid: this.config.uuid,
      token: this.config.token
    });
    this.conx.on('ready', () => {
      return done();
    });
    return this.conx.on('notReady', done);
  });
  it('should get here', function() {
    return expect(true).to.be.true;
  });
  return describe('GET /devices', function() {
    describe('when called with a valid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({}, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices" message', function() {
        expect(this.message.topic).to.deep.equal('devices');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          request: {}
        });
      });
    });
    return describe('when called with an invalid request', function() {
      return beforeEach(function(done) {
        return this.meshblu.devices({
          uuid: 'invalid-uuid'
        }, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
    });
  });
});
```

Response:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe 'GET /devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()


Prompt:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

Response:
it 'should get here', ->
    expect(true).to.be.true

  describe 'GET /devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()


Response:
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe 'GET /devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe 'GET /devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }
```

Response:
it('should send a "devices-error" message', function() {
  expect(this.message.topic).to.deep.equal('devices-error');
  return expect(this.message.payload).to.deep.equal({
    fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
    error: "Devices not found",
    request: {
      uuid: 'invalid-uuid'
    }
  });
});

describe('GET /devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = `/devices/${this.config.uuid}`;
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices" message', function() {
      expect(this.message.topic).to.deep.equal('devices');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          uuid: this.config.uuid
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = "/devices/invalid-uuid";
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices-error" message', function() {
      expect(this.message.topic).to.deep.equal('devices-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: "Devices not found",
        request: {
          uuid: 'invalid-uuid'
        }
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
it('should send a "devices-error" message', function() {
  expect(this.message.topic).to.deep.equal('devices-error');
  return expect(this.message.payload).to.deep.equal({
    fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
    error: "Devices not found",
    request: {
      uuid: 'invalid-uuid'
    }
  });
});

describe('GET /devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = `/devices/${this.config.uuid}`;
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices" message', function() {
      expect(this.message.topic).to.deep.equal('devices');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          uuid: this.config.uuid
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = "/devices/invalid-uuid";
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices-error" message', function() {
      expect(this.message.topic).to.deep.equal('devices-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: "Devices not found",
        request: {
          uuid: 'invalid-uuid'
        }
      });
    });
  });
});
```

Response:
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe 'GET /devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Prompt:
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe 'GET /devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {

Response:
fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Response:
describe 'GET /v2/whoami', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.whoami (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "whoami" message', ->
          expect(@message.topic).to.deep.equal 'whoami'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request: {}
          }

    describe 'GET /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.device @config.uuid, (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices" message', ->
          expect(@message.topic).to.deep.equal 'devices'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              uuid: @config.uuid
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.device 'invalid-uuid', (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices-error" message', ->
          expect(@message.topic).to.deep.equal 'devices-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: 'Devices not found'
            request:
              uuid: 'invalid-uuid'
          }


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
describe 'GET /v2/whoami', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.whoami (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "whoami" message', ->
          expect(@message.topic).to.deep.equal 'whoami'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request: {}
          }

    describe 'GET /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.device @config.uuid, (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices" message', ->
          expect(@message.topic).to.deep.equal 'devices'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              uuid: @config.uuid
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.device 'invalid-uuid', (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices-error" message', ->
          expect(@message.topic).to.deep.equal 'devices-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: 'Devices not found'
            request:
              uuid: 'invalid-uuid'
          }
```

Response:
describe('GET /v2/whoami', function() {
  return describe('when called with a valid request', function() {
    beforeEach(function(done) {
      return this.meshblu.whoami((error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "whoami" message', function() {
      expect(this.message.topic).to.deep.equal('whoami');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {}
      });
    });
  });
});

describe('GET /v2/devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      return this.meshblu.device(this.config.uuid, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices" message', function() {
      expect(this.message.topic).to.deep.equal('devices');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          uuid: this.config.uuid
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      return this.meshblu.device('invalid-uuid', (error) => {
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices-error" message', function() {
      expect(this.message.topic).to.deep.equal('devices-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: 'Devices not found',
        request: {
          uuid: 'invalid-uuid'
        }
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
describe('GET /v2/whoami', function() {
  return describe('when called with a valid request', function() {
    beforeEach(function(done) {
      return this.meshblu.whoami((error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "whoami" message', function() {
      expect(this.message.topic).to.deep.equal('whoami');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {}
      });
    });
  });
});

describe('GET /v2/devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      return this.meshblu.device(this.config.uuid, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices" message', function() {
      expect(this.message.topic).to.deep.equal('devices');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          uuid: this.config.uuid
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      return this.meshblu.device('invalid-uuid', (error) => {
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices-error" message', function() {
      expect(this.message.topic).to.deep.equal('devices-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: 'Devices not found',
        request: {
          uuid: 'invalid-uuid'
        }
      });
    });
  });
});
```

Response:
describe 'GET /v2/whoami', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.whoami (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "whoami" message', ->
          expect(@message.topic).to.deep.equal 'whoami'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request: {}
          }

    describe 'GET /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.device @config.uuid, (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices" message', ->
          expect(@message.topic).to.deep.equal 'devices'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              uuid: @config.uuid
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.device 'invalid-uuid', (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices-error" message', ->
          expect(@message.topic).to.deep.equal 'devices-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: 'Devices not found'
            request:
              uuid: 'invalid-uuid'
          }


Prompt:
describe 'GET /v2/whoami', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.whoami (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "whoami" message', ->
          expect(@message.topic).to.deep.equal 'whoami'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request: {}
          }

    describe 'GET /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.device @config.uuid, (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

Response:
it 'should send a "devices" message', ->
          expect(@message.topic).to.deep.equal 'devices'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              uuid: @config.uuid
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.device 'invalid-uuid', (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "devices-error" message', ->
          expect(@message.topic).to.deep.equal 'devices-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: 'Devices not found'
            request:
              uuid: 'invalid-uuid'
          }


Response:
describe 'PATCH /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, foo: 'bar', (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "update" message', ->
          expect(@message.topic).to.deep.equal 'update'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              query: {uuid: @config.uuid}
              params: {$set: {foo: 'bar'}}
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send an "update-error" message', ->
          expect(@message.topic).to.deep.equal 'update-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: "The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage."
            request:
              query: {uuid: @config.uuid}
              params: {$set: {"$foo": 'bar'}}
          }


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
describe 'PATCH /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, foo: 'bar', (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "update" message', ->
          expect(@message.topic).to.deep.equal 'update'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              query: {uuid: @config.uuid}
              params: {$set: {foo: 'bar'}}
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send an "update-error" message', ->
          expect(@message.topic).to.deep.equal 'update-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: "The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage."
            request:
              query: {uuid: @config.uuid}
              params: {$set: {"$foo": 'bar'}}
          }
```

Response:
describe('PATCH /v2/devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      return this.meshblu.update(this.config.uuid, {
        foo: 'bar'
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "update" message', function() {
      expect(this.message.topic).to.deep.equal('update');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          query: {
            uuid: this.config.uuid
          },
          params: {
            $set: {
              foo: 'bar'
            }
          }
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      return this.meshblu.update(this.config.uuid, {
        $foo: 'bar'
      }, (error) => {
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send an "update-error" message', function() {
      expect(this.message.topic).to.deep.equal('update-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: "The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.",
        request: {
          query: {
            uuid: this.config.uuid
          },
          params: {
            $set: {
              "$foo": 'bar'
            }
          }
        }
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
describe('PATCH /v2/devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      return this.meshblu.update(this.config.uuid, {
        foo: 'bar'
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "update" message', function() {
      expect(this.message.topic).to.deep.equal('update');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          query: {
            uuid: this.config.uuid
          },
          params: {
            $set: {
              foo: 'bar'
            }
          }
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      return this.meshblu.update(this.config.uuid, {
        $foo: 'bar'
      }, (error) => {
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send an "update-error" message', function() {
      expect(this.message.topic).to.deep.equal('update-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: "The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.",
        request: {
          query: {
            uuid: this.config.uuid
          },
          params: {
            $set: {
              "$foo": 'bar'
            }
          }
        }
      });
    });
  });
});
```

Response:
describe 'PATCH /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, foo: 'bar', (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "update" message', ->
          expect(@message.topic).to.deep.equal 'update'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              query: {uuid: @config.uuid}
              params: {$set: {foo: 'bar'}}
          }

      describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send an "update-error" message', ->
          expect(@message.topic).to.deep.equal 'update-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: "The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage."
            request:
              query: {uuid: @config.uuid}
              params: {$set: {"$foo": 'bar'}}
          }


Prompt:
describe 'PATCH /v2/devices/:uuid', ->
      describe 'when called with a valid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, foo: 'bar', (error) =>
            return done error if error?
            @conx.once 'message', (@message) =>
              done()

        it 'should send a "update" message', ->
          expect(@message.topic).to.deep.equal 'update'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            request:
              query: {uuid: @config.uuid}
              params: {$set: {foo: 'bar'}}
          }

Response:
describe 'when called with an invalid request', ->
        beforeEach (done) ->
          @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>
            @conx.once 'message', (@message) =>
              done()

        it 'should send an "update-error" message', ->
          expect(@message.topic).to.deep.equal 'update-error'
          expect(@message.payload).to.deep.equal {
            fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
            error: "The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage."
            request:
              query: {uuid: @config.uuid}
              params: {$set: {"$foo": 'bar'}}
          }


Response:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()
```

Response:
var MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;

_ = require('lodash');

path = require('path');

url = require('url');

MeshbluHTTP = require('meshblu-http');

MeshbluConfig = require('meshblu-config');

meshblu = require('meshblu');

request = require('request');

describe('REST', function() {
  before(function(done) {
    var filename;
    filename = path.join(__dirname, 'meshblu.json');
    this.config = new MeshbluConfig({
      filename: filename
    }).toJSON();
    this.meshblu = new MeshbluHTTP(this.config);
    this.conx = meshblu.createConnection({
      server: this.config.server,
      port: this.config.port,
      uuid: this.config.uuid,
      token: this.config.token
    });
    this.conx.on('ready', () => {
      return done();
    });
    return this.conx.on('notReady', done);
  });
  it('should get here', function() {
    return expect(true).to.be.true;
  });
  return describe('/devices', function() {
    describe('when called with a valid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({}, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices" message', function() {
        expect(this.message.topic).to.deep.equal('devices');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          request: {}
        });
      });
    });
    return describe('when called with an invalid request', function() {
      return beforeEach(function(done) {
        return this.meshblu.devices({
          uuid: 'invalid-uuid'
        }, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;

_ = require('lodash');

path = require('path');

url = require('url');

MeshbluHTTP = require('meshblu-http');

MeshbluConfig = require('meshblu-config');

meshblu = require('meshblu');

request = require('request');

describe('REST', function() {
  before(function(done) {
    var filename;
    filename = path.join(__dirname, 'meshblu.json');
    this.config = new MeshbluConfig({
      filename: filename
    }).toJSON();
    this.meshblu = new MeshbluHTTP(this.config);
    this.conx = meshblu.createConnection({
      server: this.config.server,
      port: this.config.port,
      uuid: this.config.uuid,
      token: this.config.token
    });
    this.conx.on('ready', () => {
      return done();
    });
    return this.conx.on('notReady', done);
  });
  it('should get here', function() {
    return expect(true).to.be.true;
  });
  return describe('/devices', function() {
    describe('when called with a valid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({}, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices" message', function() {
        expect(this.message.topic).to.deep.equal('devices');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          request: {}
        });
      });
    });
    return describe('when called with an invalid request', function() {
      return beforeEach(function(done) {
        return this.meshblu.devices({
          uuid: 'invalid-uuid'
        }, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
    });
  });
});
```

Response:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()


Prompt:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

Response:
it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()


Response:
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe '/devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe '/devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }
```

Response:
it('should send a "devices-error" message', function() {
  expect(this.message.topic).to.deep.equal('devices-error');
  return expect(this.message.payload).to.deep.equal({
    fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
    error: "Devices not found",
    request: {
      uuid: 'invalid-uuid'
    }
  });
});

describe('/devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = `/devices/${this.config.uuid}`;
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices" message', function() {
      expect(this.message.topic).to.deep.equal('devices');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          uuid: this.config.uuid
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = "/devices/invalid-uuid";
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices-error" message', function() {
      expect(this.message.topic).to.deep.equal('devices-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: "Devices not found",
        request: {
          uuid: 'invalid-uuid'
        }
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
it('should send a "devices-error" message', function() {
  expect(this.message.topic).to.deep.equal('devices-error');
  return expect(this.message.payload).to.deep.equal({
    fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
    error: "Devices not found",
    request: {
      uuid: 'invalid-uuid'
    }
  });
});

describe('/devices/:uuid', function() {
  describe('when called with a valid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = `/devices/${this.config.uuid}`;
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices" message', function() {
      expect(this.message.topic).to.deep.equal('devices');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        request: {
          uuid: this.config.uuid
        }
      });
    });
  });
  return describe('when called with an invalid request', function() {
    beforeEach(function(done) {
      var auth, pathname, uri;
      pathname = "/devices/invalid-uuid";
      uri = url.format({
        protocol: this.config.protocol,
        hostname: this.config.server,
        port: this.config.port,
        pathname: pathname
      });
      auth = {
        user: this.config.uuid,
        pass: this.config.token
      };
      return request.get(uri, {
        auth: auth
      }, (error) => {
        if (error != null) {
          return done(error);
        }
        return this.conx.once('message', (message) => {
          this.message = message;
          return done();
        });
      });
    });
    return it('should send a "devices-error" message', function() {
      expect(this.message.topic).to.deep.equal('devices-error');
      return expect(this.message.payload).to.deep.equal({
        fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
        error: "Devices not found",
        request: {
          uuid: 'invalid-uuid'
        }
      });
    });
  });
});
```

Response:
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe '/devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Prompt:
it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }

  describe '/devices/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {

Response:
fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request:
            uuid: @config.uuid
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        pathname = "/devices/invalid-uuid"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        auth = user: @config.uuid, pass: @config.token
        request.get uri, auth: auth,  (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Response:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"


Prompt:
_ = require 'lodash'
path = require 'path'
url = require 'url'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'
request = require 'request'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

Response:
describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"


Response:
request:
            uuid: 'invalid-uuid'
        }

  describe '/device/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"
        uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        request.get uri, (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "device" message', ->
        expect(@message.topic).to.deep.equal 'device'


Prompt:
request:
            uuid: 'invalid-uuid'
        }

  describe '/device/:uuid', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        pathname = "/devices/#{@config.uuid}"

Response:
uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname
        request.get uri, (error) =>
          return done error if error?
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "device" message', ->
        expect(@message.topic).to.deep.equal 'device'


Response:
path = require 'path'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
path = require 'path'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }
```

Response:
var MeshbluConfig, MeshbluHTTP, meshblu, path;

path = require('path');

MeshbluHTTP = require('meshblu-http');

MeshbluConfig = require('meshblu-config');

meshblu = require('meshblu');

describe('REST', function() {
  before(function(done) {
    var filename;
    filename = path.join(__dirname, 'meshblu.json');
    this.config = new MeshbluConfig({
      filename: filename
    }).toJSON();
    this.meshblu = new MeshbluHTTP(this.config);
    this.conx = meshblu.createConnection({
      server: this.config.server,
      port: this.config.port,
      uuid: this.config.uuid,
      token: this.config.token
    });
    this.conx.on('ready', () => {
      return done();
    });
    return this.conx.on('notReady', done);
  });
  it('should get here', function() {
    return expect(true).to.be.true;
  });
  return describe('/devices', function() {
    describe('when called with a valid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({}, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices" message', function() {
        expect(this.message.topic).to.deep.equal('devices');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          request: {}
        });
      });
    });
    return describe('when called with an invalid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({
          uuid: 'invalid-uuid'
        }, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices-error" message', function() {
        expect(this.message.topic).to.deep.equal('devices-error');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          error: "Devices not found",
          request: {
            uuid: 'invalid-uuid'
          }
        });
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var MeshbluConfig, MeshbluHTTP, meshblu, path;

path = require('path');

MeshbluHTTP = require('meshblu-http');

MeshbluConfig = require('meshblu-config');

meshblu = require('meshblu');

describe('REST', function() {
  before(function(done) {
    var filename;
    filename = path.join(__dirname, 'meshblu.json');
    this.config = new MeshbluConfig({
      filename: filename
    }).toJSON();
    this.meshblu = new MeshbluHTTP(this.config);
    this.conx = meshblu.createConnection({
      server: this.config.server,
      port: this.config.port,
      uuid: this.config.uuid,
      token: this.config.token
    });
    this.conx.on('ready', () => {
      return done();
    });
    return this.conx.on('notReady', done);
  });
  it('should get here', function() {
    return expect(true).to.be.true;
  });
  return describe('/devices', function() {
    describe('when called with a valid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({}, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices" message', function() {
        expect(this.message.topic).to.deep.equal('devices');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          request: {}
        });
      });
    });
    return describe('when called with an invalid request', function() {
      beforeEach(function(done) {
        return this.meshblu.devices({
          uuid: 'invalid-uuid'
        }, () => {
          return this.conx.once('message', (message) => {
            this.message = message;
            return done();
          });
        });
      });
      return it('should send a "devices-error" message', function() {
        expect(this.message.topic).to.deep.equal('devices-error');
        return expect(this.message.payload).to.deep.equal({
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a",
          error: "Devices not found",
          request: {
            uuid: 'invalid-uuid'
          }
        });
      });
    });
  });
});
```

Response:
path = require 'path'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }


Prompt:
path = require 'path'
MeshbluHTTP = require 'meshblu-http'
MeshbluConfig = require 'meshblu-config'
meshblu = require 'meshblu'

describe 'REST', ->
  before (done) ->
    filename = path.join __dirname, 'meshblu.json'
    @config = new MeshbluConfig(filename: filename).toJSON()
    @meshblu = new MeshbluHTTP @config
    @conx = meshblu.createConnection
      server : @config.server
      port   : @config.port
      uuid   : @config.uuid
      token  : @config.token

    @conx.on 'ready', => done()
    @conx.on 'notReady', done

  it 'should get here', ->
    expect(true).to.be.true

  describe '/devices', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->

Response:
@meshblu.devices {}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices" message', ->
        expect(@message.topic).to.deep.equal 'devices'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          request: {}
        }

    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @meshblu.devices {uuid: 'invalid-uuid'}, =>
          @conx.once 'message', (@message) =>
            done()

      it 'should send a "devices-error" message', ->
        expect(@message.topic).to.deep.equal 'devices-error'
        expect(@message.payload).to.deep.equal {
          fromUuid: "66b2928b-a317-4bc3-893e-245946e9672a"
          error: "Devices not found"
          request:
            uuid: 'invalid-uuid'
        }