Sha256: e7de61fe6766be105274bde117ecb8b6ce7ea06b294b719ceaa702216f7188dd

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe SlackRubyBot::Commands do
  let! :command do
    Class.new(SlackRubyBot::Commands::Base) do
      command 'send_gif_spec' do |client, data, _match|
        send_gif client, data.channel, 'dummy'
      end
    end
  end
  def app
    SlackRubyBot::App.new
  end
  let(:client) { app.send(:client) }
  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(SlackRubyBot::Commands::Base).to receive(:send_client_message).with(client, channel: 'channel', text: gif_image_url)
    app.send(:message, client, text: "#{SlackRubyBot.config.user} send_gif_spec message", channel: 'channel', user: 'user')
  end
  it 'eats up the error' do
    expect(Giphy).to receive(:random) { fail 'oh no!' }
    expect(SlackRubyBot::Commands::Base).to receive(:send_client_message).with(client, channel: 'channel', text: '')
    app.send(:message, client, text: "#{SlackRubyBot.config.user} send_gif_spec message", channel: 'channel', user: 'user')
  end
  it 'eats up nil gif' do
    expect(Giphy).to receive(:random).and_return(nil)
    expect(SlackRubyBot::Commands::Base).to receive(:send_client_message).with(client, channel: 'channel', text: '')
    app.send(:message, client, text: "#{SlackRubyBot.config.user} send_gif_spec message", channel: 'channel', user: 'user')
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
slack-ruby-bot-bhe-0.5.5.3 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.5.5 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.5.4 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.5.3 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.5.2 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.5.1 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.5.0 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.4.5 spec/slack-ruby-bot/commands/send_gif_spec.rb
slack-ruby-bot-0.4.4 spec/slack-ruby-bot/commands/send_gif_spec.rb