A Slack Bot that pulls Pixiv information and posts the full image(s) into Slack, with iOS shortcuts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

30 lines
828 B

require 'rspec/expectations'
RSpec::Matchers.define :respond_with_error do |expected|
match do |actual|
channel, user, message = parse(actual)
app = SlackMathbot::App.new
SlackMathbot.config.user = 'mathbot'
begin
expect do
app.send(:message, text: message, channel: channel, user: user)
end.to raise_error ArgumentError, expected
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