Sha256: 588b9605541c3344bea98907844a8e530c966646a2cc0cdb7748b4fcf08fa327

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

require 'rspec/expectations'

RSpec::Matchers.define :not_respond do
  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)

    expect(client).not_to receive(:message)
    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

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-bot-0.10.5 lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb
slack-ruby-bot-0.10.4 lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb