Coffeescript Hubot单元测试未收到响应

Coffeescript Hubot单元测试未收到响应,coffeescript,mocha.js,chai,hubot,Coffeescript,Mocha.js,Chai,Hubot,我正试图为我的hubot代码设置一个简单的单元测试,但我没有收到回复。我将此简化为: 测试。咖啡: Helper = require('hubot-test-helper') chai = require 'chai' expect = chai.expect helper = new Helper('../hubot-scripts/something.coffee') describe 'PING', -> beforeEach -> @room = h

我正试图为我的hubot代码设置一个简单的单元测试,但我没有收到回复。我将此简化为:

测试。咖啡:

Helper = require('hubot-test-helper')
chai = require 'chai'
expect = chai.expect
helper = new Helper('../hubot-scripts/something.coffee')

describe 'PING', ->
    beforeEach ->
        @room = helper.createRoom()
    afterEach ->
        @room.destroy

    it 'should PONG', ->
        @room.user.say 'alice', '@hubot PING'
        expect(@room.messages).to.eql [
            ['alice', '@hubot PING'],
            ['hubot', 'PONG']
        ]
还有,咖啡:

module.exports = (robot) ->
    robot.response /PING$/i, (msg) ->
        msg.send 'PONG'
当我运行测试时,我得到一个断言错误:

  AssertionError: expected [ [ 'alice', '@hubot PING' ] ] to deeply equal [ Array(2) ]
  + expected - actual

     [
       "alice"
       "@hubot PING"
     ]
  +  [
  +    "hubot"
  +    "PONG"
  +  ]
   ]
这意味着我根本没有得到回复。我试着把@hubot改成hubot(这没关系)。我还验证了它正在查找我的某物。咖啡,因为当我将该路径更改为错误路径时,我收到了一个关于该路径的错误

我遵循的是本书底部的例子


谢谢你的帮助

我不知道为什么,但将@room.user.say移动到一个before块中,这就成功了。

对于任何到达此线程的人,我在遇到相同问题时发布了一条消息。
简而言之,问题是缩进-在执行
@room.user.say
之前调用了以
expect
开头的行。有关更多详细信息,请查看我的链接。

您能发布您的代码吗?我也有同样的问题,但不明白你的指示。我已经创建了一个before->,并将整个测试放在其中。