Open
Description
Hi,
When trying to rspec test a command such as:
command('support', &->(client, data, match){
channel_real_name = client.channels.dig(data.channel, :name)
client.say(channel: data.channel,
text: "#{channel_real_name} support url: https://url")
})
with the following spec file:
require_relative '../commands/support'
require 'pry'
describe MyBot::Commands::Support do
it 'gives support link' do
expect(message: "#{SlackRubyBot.config.user} support").to respond_with_slack_message(/support url/)
end
end
and spec_helper:
require 'slack-ruby-bot/rspec'
require 'webmock/rspec'
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'yaml'
require 'json'
require 'async'
require_relative '../mybot'
When running rspec I get:
1) MyBot::Commands::Support gives support link
Failure/Error: client.channels.dig(data.channel, :name)
NoMethodError:
undefined method `dig' for nil:NilClass
Whereas I'm expecting to get a green passing test.
In order to get over the error I think I need to connect to slack but I can’t find the proper documentation for doing so.
Thanks