Sha256: babf42c4fce9df601f21b4d9ed80be524020f90faf0f6ea7cedbefa73462c556

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require File.dirname(__FILE__) + "/../helper"

module Roflbot
  class TestSentenceBot < Test::Unit::TestCase
    def setup
      super
      @options = {
        "accounts" => {
          "AIM" => {"username" => 'dudeguy', "password" => 'password'},
          "Twitter" => { "token" => "abcdef", "secret" => "123456" }
        },
        "sentences" => ["Hey (noun), (ending)"],
        "noun" => %w{dude guy},
        "ending" => ["sup?", "I love you."]
      }
    end

    def test_base_superclass
      assert_equal Base, SentenceBot.superclass
    end

    def test_responses
      bot = SentenceBot.new(@options)

      @buddy.expects(:send_im).times(20).with do |message|
        message =~ /^Hey (dude|guy), (sup\?|I love you.)$/
      end
      20.times { |_| receive_im("hey") }
    end

    def test_parses_quotes
      @options["sentences"] = ["You're awesome (noun), (ending)"]
      bot = SentenceBot.new(@options)

      @buddy.expects(:send_im).times(20).with do |message|
        message =~ /^You're awesome (dude|guy), (sup\?|I love you.)$/
      end
      20.times { |_| receive_im("hey") }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roflbot-0.0.6 test/roflbot/test_sentence_bot.rb
roflbot-0.0.5 test/roflbot/test_sentence_bot.rb
roflbot-0.0.4 test/roflbot/test_sentence_bot.rb