'use strict';

var GamesController = require('../../app/controllers/games');

describe('GamesController', function () {
  context('#index', function () {
    it('should list all games', function (done) {
      GameController.index(null, { json: function () {
        catching(done, function () {
        });
      }});
    });
  });

  context('#create', function () {
    it('should create a new game', function (done) {
      GameController.create({ body: { players: [] }}, {
        json: function () {
          catching(done, function () {
            expect(Game.prototype.save.calledOnce).to.be.true;
          });
        }
      });
    });
  });
  
  context.only('#waiting', function () {
    it('should add player to the waiting list', function () {
      var player = 'player' + Math.random();
      GamesController.waiting({
        body: {
          player: player
        }
      }, {
        json: function () {
          GamesController._waiting.should.contain(player);
        }
      })
    });

    it('should validate presence of player', function () {
      GamesController.waiting({
        body: {
          player: ''
        }
      }, {
        json: function (status, res) {
          status.should.equal(422);
        }
      })
    });
  });
});

@@ -122,16 +122,21 @@
  context
+.only
 ('#index
@@ -144,32 +144,32 @@
 , function () %7B%0A
-
     it('should l
@@ -204,32 +204,33 @@
 ne) %7B%0A      Game
+s
 Controller.index
@@ -246,32 +246,35 @@
 json: function (
+res
 ) %7B%0A        catc
@@ -273,36 +273,56 @@
     
-catching(done, function () %7B
+res.should.deep.equal(GamesController._waiting);
 %0A   
@@ -318,33 +318,37 @@
 iting);%0A        
-%7D
+done(
 );%0A      %7D%7D);%0A  
@@ -694,21 +694,16 @@
  context
-.only
 ('#waiti

fix games#index tests