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

  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. begin
  8. expect do
  9. app.send(:message, text: message, channel: channel, user: user)
  10. end.to raise_error ArgumentError, expected
  11. rescue RSpec::Expectations::ExpectationNotMetError => e
  12. @error_message = e.message
  13. raise e
  14. end
  15. true
  16. end
  17. failure_message do |actual|
  18. _, _, message = parse(actual)
  19. @error_message || "expected for '#{message}' to fail with '#{expected}'"
  20. end
  21. private
  22. def parse(actual)
  23. actual = { message: actual } unless actual.is_a?(Hash)
  24. [actual[:channel] || 'channel', actual[:user] || 'user', actual[:message]]
  25. end
  26. end