Sha256: 34c305b238341926c3bb19766faec717f26412c563ef666da2f027c6f67a2d5d
Contents?: true
Size: 862 Bytes
Versions: 2
Compression:
Stored size: 862 Bytes
Contents
require 'rspec/expectations' RSpec::Matchers.define :respond_with_error do |error, error_message| match do |actual| channel, user, message = parse(actual) allow(Giphy).to receive(:random) begin expect do client = app.send(:client) app.send(:message, client, Hashie::Mash.new(text: message, channel: channel, user: user)) end.to raise_error error, error_message rescue RSpec::Expectations::ExpectationNotMetError => e @error_message = e.message raise e end true end failure_message do |actual| _, _, message = parse(actual) @error_message || "expected for '#{message}' to fail with '#{expected}'" 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.7.0 | lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb |
slack-ruby-bot-0.6.2 | lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb |