问题描述
我一直在为通道实现一个基本的松弛机器人,并且由于代码非常简单,所以我没有公共方法。只是来自slack-ruby-bot gem的命令。但是作为项目要求,我需要在项目中添加几个单元测试。基本上,当我发出@ruby_codes字符串命令时,它会给我该区域的Wiki页面。我该如何测试?附加了我的版本,但每次都失败。
我的命令示例如下:
module RubyCodes
# SlackBot command methods#
class GetWiki < slackrubyBot::Commands::Base
command 'strings' do |client,data,_match|
client.say(channel: data.channel,text: 'https://en.wikipedia.org/wiki/Ruby_(programming_language)#Strings')
end
我的测试用例如下:
describe slackrubyBot::Commands do
it 'returns ruby strings wiki page' do
expect(message: "#{slackrubyBot.config.user} strings").to respond_with_slack_message('https://en.wikipedia.org/wiki/Ruby_(programming_language)#Strings')
end
end
谢谢!
另外,这是我得到的错误:
expected to receive message with text: https://en.wikipedia.org/wiki/Ruby_(programming_language)#Strings once,received:[{:text=>"Sorry <@user>,I don't understand that command!",:channel=>"channel"}]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)