Sha256: 31a6dade55f62393183f785ef20d5675680aff10befc34216c3a93bcfd884605

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

require 'rspec/expectations'

RSpec::Matchers.define :respond_with_slack_message do |expected|
  match do |actual|
    channel, user, message = parse(actual)
    allow(Giphy).to receive(:random)
    client = app.send(:client)
    expect(client).to receive(:message).with(channel: channel, text: expected)
    app.send(:message, client, 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.6.1 lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb
slack-ruby-bot-0.6.0 lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb