Sha256: f5bc30b560187d4ad98f5a4be93834a84c9c7615cbb049f398106c877e0ffbef

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

require 'test_helper'
require 'robut/plugin/pick'
require 'mocha/setup'

class Robut::Plugin::PickTest < Test::Unit::TestCase

  def setup
    @connection = Robut::ConnectionMock.new
    @presence = Robut::PresenceMock.new(@connection)
    @plugin = Robut::Plugin::Pick.new(@presence)
  end

  def test_replies_with_correct_response
    @plugin.stubs(:random).returns(0)
    @plugin.handle(Time.now, "@john", "@robut pick a, b, c")
    assert_equal ["And the winner is... a"], @plugin.reply_to.replies
  end

  def test_does_nothing_when_no_options_are_given
    @plugin.handle(Time.now, "@john", "@robut pick")
    assert @plugin.reply_to.replies.empty?
  end

  def test_replies_only_option_if_given_one_options
    @plugin.handle(Time.now, "@john", "@robut pick a")
    assert_equal ["And the winner is... a"], @plugin.reply_to.replies
  end

  def test_handles_spaces
    @plugin.stubs(:random).returns(1)
    @plugin.handle(Time.now, "@john", "@robut pick this is the first option, this is the second option, this is the third option")
    assert_equal ["And the winner is... this is the second option"], @plugin.reply_to.replies
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sclemmer-robut-0.6.3 test/unit/plugin/pick_test.rb
sclemmer-robut-0.6.2 test/unit/plugin/pick_test.rb
sclemmer-robut-0.6.1 test/unit/plugin/pick_test.rb
robut-0.5.2 test/unit/plugin/pick_test.rb