Sha256: 8588dacac679377144418039a562504c88d1937c75642b64661e4b651bf1e1b2
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require 'rspec/expectations' RSpec::Matchers.define :respond_with_slack_message do |expected| include SlackRubyBot::SpecHelpers match do |actual| client = respond_to?(:client) ? send(:client) : SlackRubyBot::Client.new message_command = SlackRubyBot::Hooks::Message.new channel, user, message, attachments = parse(actual) allow(Giphy).to receive(:random) if defined?(Giphy) allow(client).to receive(:message) do |options| @messages ||= [] @messages.push options end message_command.call(client, Hashie::Mash.new(text: message, channel: channel, user: user, attachments: attachments)) matcher = have_received(:message).once matcher = matcher.with(hash_including(channel: channel, text: expected)) if channel && expected expect(client).to matcher true end failure_message do |_actual| message = "expected to receive message with text: #{expected} once,\n received:" message += @messages&.any? ? @messages.inspect : 'none' message end end
Version data entries
3 entries across 3 versions & 1 rubygems