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.

31 lines
865 B

  1. require 'rspec/expectations'
  2. RSpec::Matchers.define :respond_with_error do |expected|
  3. match do |actual|
  4. channel, user, message = parse(actual)
  5. app = SlackMathbot::App.new
  6. SlackMathbot.config.user = 'mathbot'
  7. allow(Giphy).to receive(:random)
  8. begin
  9. expect do
  10. app.send(:message, text: message, channel: channel, user: user)
  11. end.to raise_error ArgumentError, expected
  12. rescue RSpec::Expectations::ExpectationNotMetError => e
  13. @error_message = e.message
  14. raise e
  15. end
  16. true
  17. end
  18. failure_message do |actual|
  19. _, _, message = parse(actual)
  20. @error_message || "expected for '#{message}' to fail with '#{expected}'"
  21. end
  22. private
  23. def parse(actual)
  24. actual = { message: actual } unless actual.is_a?(Hash)
  25. [actual[:channel] || 'channel', actual[:user] || 'user', actual[:message]]
  26. end
  27. end