 Q = require 'q'
 _ = require 'underscore'
+mute = require 'mute'
 {inspect} = require 'util'
 sinon = require 'sinon'
 chai = require 'chai'

    _.invoke @spy, 'restore' # restore all the methods
    @room.destroy()

  context 'Create a Dialogue with defaults', ->

    beforeEach -> @dialogue = new Dialogue @res
    afterEach -> clearTimeout @dialogue.countdown

    it 'inherits event emmiter', ->
      @dialogue.should.be.instanceof EventEmitter
      @dialogue.emit.should.be.instanceof Function

    it 'has the logger from response object robot', ->
      @dialogue.logger.should.eql @room.robot.logger

    it 'has an empty choices array', ->
      @dialogue.choices.should.be.an 'Array'
      @dialogue.choices.length.should.equal 0

    it 'has config with defaults of correct type', ->
      @dialogue.config.isObject
      @dialogue.config.timeout.isNumber
      @dialogue.config.timeoutLine.isString

    it 'starts timeout', ->
      @dialogue.countdown.should.exist
      @dialogue.countdown.should.be.instanceof Timeout
      @spy.startTimeout.should.have.been.calledOnce

  context 'Create a Dialogue with env vars', ->

    beforeEach ->
      process.env.DIALOGUE_TIMEOUT = 500

      @dialogue.config.timeout.should.equal 555
      @dialogue.config.timeoutLine.should.equal 'Testing timeout options'

  context 'Dialogue created with 100ms timeout', ->

    beforeEach (done) ->
      @eventSpy = sinon.spy()
