Sha256: 74ea6cfce0fa1b19fb72bca0f54d8527944ce2de24cb8a12f616d3146c9ef469

Contents?: true

Size: 1005 Bytes

Versions: 5

Compression:

Stored size: 1005 Bytes

Contents

describe SlackRubyBot::Commands, if: ENV.key?('WITH_GIPHY') do
  let! :command do
    Class.new(SlackRubyBot::Commands::Base) do
      command 'send_gif_spec' do |client, data, _match|
        client.say(channel: data.channel, gif: 'dummy')
      end
    end
  end

  let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' }

  it 'sends a gif' do
    gif = Giphy::RandomGif.new('image_url' => gif_image_url)
    expect(Giphy).to receive(:random).and_return(gif)
    expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message(gif_image_url)
  end
  it 'eats up the error' do
    expect(Giphy).to receive(:random) { raise 'oh no!' }
    expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message('')
  end
  it 'eats up nil gif' do
    expect(Giphy).to receive(:random).and_return(nil)
    expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message('')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-bot-0.11.0 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.10.5 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.10.4 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.10.3 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.10.2 spec/slack-ruby-bot/commands/send_gif_spec.rb