Hubot 单元测试未收到响应 [英] Hubot Unit Testing Not Receiving Response

查看:25
本文介绍了Hubot 单元测试未收到响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的 hubot 代码设置一个简单的单元测试,但我没有收到回复.我已将其简化为:

I'm trying to set up a simple unit test for my hubot code and I am not receiving responses back. I have simplified this down to:

test.coffee:

test.coffee:

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'

当我运行测试时,我收到以下断言错误:

When I run my tests, I get an assertion error of:

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

     [
       "alice"
       "@hubot PING"
     ]
  +  [
  +    "hubot"
  +    "PONG"
  +  ]
   ]

意思是我根本没有得到回复.我尝试将@hubot 更改为hubot(这没关系).我还验证了它正在找到我的 something.coffee,因为当我将该路径更改为不正确的路径时,我收到了一个错误.

Meaning I am not getting a response back at all. I have tried changing @hubot to hubot (which shouldn't matter). I also verified that it is finding my something.coffee, as when I changed that path to an incorrect one I received an error about that.

我正在关注 https://hubot.github.com/docs/底部的示例脚本/

感谢您的帮助!

推荐答案

对于任何到达此线程的人,我发布了一个 问题.简而言之,问题是缩进 - 在执行 @room.user.say 之前调用了以 expect 开头的行.详情请看我的链接.

For anyone who reached this thread, I posted a question when I experienced the same issue. In short, the issue was indentation - the line beginning with expect was being called before the @room.user.say was executed. Please see my link for more details.

这篇关于Hubot 单元测试未收到响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆