Sha256: 635007368d065fc94123a640161c615e54fefdb52af486d82e9269bb34714fa3

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'test_helper'
require 'robut/plugin/giphy/meme'

class Robut::Plugin::Giphy::MemeTest < Test::Unit::TestCase
  include GiphyTestBase

  def test_replies_with_one_line
    @plugin.handle(Time.now, "@john", "@robut giphy american psycho; text on a picture")
    assert_equal ["http://v1.memecaptain.com/i?u=http://s3.amazonaws.com/giphygifs/media/Ggjwvmqktuvf2/giphy.gif&tt=text+on+a+picture\nPowered by Giphy and MemeCaptain"], @plugin.reply_to.replies
  end

  def test_replies_with_two_lines
    @plugin.handle(Time.now, "@john", "@robut giphy american psycho; text on a picture; isn't it awesome")
    assert_equal ["http://v1.memecaptain.com/i?u=http://s3.amazonaws.com/giphygifs/media/Ggjwvmqktuvf2/giphy.gif&tt=text+on+a+picture&tb=isn%27t+it+awesome\nPowered by Giphy and MemeCaptain"], @plugin.reply_to.replies
  end

  def test_replies_without_gif
    @plugin.handle(Time.now, "@john", "@robut giphy hjklxxxx; blargh")
    assert_equal ["Sorry, I couldn't find a gif for that."], @plugin.reply_to.replies
  end
  
  def test_replies_with_three_semicolons
    @plugin.handle(Time.now, "@john", "@robut giphy american psycho; text on a picture; isn't it awesome; so very awesome")
    assert_equal ["That's too much text. Don't be greedy."], @plugin.reply_to.replies
  end

  def test_ignores_giphy_without_semicolons
    @plugin.handle(Time.now, "@john", "@robut giphy cat")
    assert_equal [], @plugin.reply_to.replies
  end

  protected
  def new_plugin(presence)
    Robut::Plugin::Giphy::Meme.new(presence)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
robut-giphy-0.1.0 test/unit/plugin/meme_test.rb