Sha256: d306125e33fac5876ad8441c7db95e165d8595304dd99e79d62760b0dc7b3243
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true describe SlackRubyBot::Commands, if: WithGiphy.env? do let! :command do Class.new(SlackRubyBot::Commands::Base) do command 'send_message_with_gif_spec' do |client, data, match| client.say(channel: data.channel, text: match['expression'], gif: 'dummy') end end end let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' } let(:gif) { OpenStruct.new('image_url' => gif_image_url) } it 'sends a message with gif' do expect(Giphy).to receive(:random).and_return(gif) expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message("message\n#{gif_image_url}") end it 'eats up errors' do expect(Giphy).to receive(:random) { raise 'oh no!' } expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message') end it 'eats up nil gif' do expect(Giphy).to receive(:random).and_return(nil) expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message') end context 'when client.send_gifs is false' do let :client do SlackRubyBot::Client.new.tap { |c| c.send_gifs = false } end it 'does not send a gif' do expect(Giphy).to_not receive(:random) expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message') end end end
Version data entries
3 entries across 3 versions & 1 rubygems