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.

32 lines
1.6 KiB

9 years ago
  1. require 'spec_helper'
  2. describe SlackRubyBot::Commands do
  3. let! :command do
  4. Class.new(SlackRubyBot::Commands::Base) do
  5. command 'send_message_with_gif_spec' do |client, data, match|
  6. send_message_with_gif client, data.channel, match['expression'], 'dummy'
  7. end
  8. end
  9. end
  10. def app
  11. SlackRubyBot::App.new
  12. end
  13. let(:client) { app.send(:client) }
  14. let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' }
  15. it 'sends a message with gif' do
  16. gif = Giphy::RandomGif.new('image_url' => gif_image_url)
  17. expect(Giphy).to receive(:random).and_return(gif)
  18. expect(SlackRubyBot::Commands::Base).to receive(:send_client_message).with(client, channel: 'channel', text: "message\n#{gif_image_url}")
  19. app.send(:message, client, text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user')
  20. end
  21. it 'eats up the error' do
  22. expect(Giphy).to receive(:random) { fail 'oh no!' }
  23. expect(SlackRubyBot::Commands::Base).to receive(:send_client_message).with(client, channel: 'channel', text: 'message')
  24. app.send(:message, client, text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user')
  25. end
  26. it 'eats up nil gif' do
  27. expect(Giphy).to receive(:random).and_return(nil)
  28. expect(SlackRubyBot::Commands::Base).to receive(:send_client_message).with(client, channel: 'channel', text: 'message')
  29. app.send(:message, client, text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user')
  30. end
  31. end