Sha256: 7adfb840196a27beb7caf76920661d3cb10d18c8c7eba5ff52403a52e1835bf8
Contents?: true
Size: 783 Bytes
Versions: 6
Compression:
Stored size: 783 Bytes
Contents
require 'rspec/expectations' RSpec::Matchers.define :respond_with_slack_message do |expected| match do |actual| client = if respond_to?(:client) send(:client) else SlackRubyBot::Client.new end message_command = SlackRubyBot::Hooks::Message.new channel, user, message = parse(actual) allow(Giphy).to receive(:random) if defined?(Giphy) expect(client).to receive(:message).with(channel: channel, text: expected) message_command.call(client, Hashie::Mash.new(text: message, channel: channel, user: user)) true end private def parse(actual) actual = { message: actual } unless actual.is_a?(Hash) [actual[:channel] || 'channel', actual[:user] || 'user', actual[:message]] end end
Version data entries
6 entries across 6 versions & 1 rubygems