Sha256: aeff4de36d5cdf1a3806b68f6d9c95ac89e2cefb574347ba4b9b2458ef90f1be

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'
require 'robut/plugin/echo'

class MucMock
  attr_accessor :messages, :room

  def initialize
    @messages = []
    @room = ''
  end

  def join(room)
    @room = room
  end

  def send(message)
    @messages << message
  end

  def on_message(*args, &block)
    if block_given?
      @message_block = block
    else
      @message_block.call(args)
    end
  end
end

class RoomTest < Test::Unit::TestCase
  def setup
    Robut::Plugin.plugins = [Robut::Plugin::Echo]
    connection = Robut::ConnectionMock.new(OpenStruct.new(:nick => 'Dodo'))
    @room = Robut::Room.new(connection, 'fake_room')
  end

  def test_room_receives_correct_message
    message = 'Huzzah!'
    @room.muc = MucMock.new
    @room.join

    @room.muc.on_message(Time.now, "Art Vandelay", "@dodo echo #{message}")
    assert_equal @room.muc.messages.first.body, message
  end

  def test_joining_the_right_room
    @room.muc = MucMock.new
    @room.join

    assert_equal @room.muc.room, "#{@room.name}/#{@room.connection.config.nick}"
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
sclemmer-robut-0.6.3 test/unit/room_test.rb
sclemmer-robut-0.6.2 test/unit/room_test.rb
sclemmer-robut-0.6.1 test/unit/room_test.rb
sclemmer-robut-0.6.0 test/unit/room_test.rb
sclemmer-robut-0.5.4 test/unit/room_test.rb
sclemmer-robut-0.5.3 test/unit/room_test.rb
sclemmer-robut-0.5.2 test/unit/room_test.rb
robut-0.5.2 test/unit/room_test.rb
robut-0.5.1 test/unit/room_test.rb
robut-0.5.0 test/unit/room_test.rb
robut-0.4.0 test/unit/room_test.rb