1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'spec_helper'
require 'ponder/thaum'
describe Ponder::IRC do
before(:each) do
@ponder = Ponder::Thaum.new do |t|
t.nick = 'Ponder'
t.username = 'Ponder'
t.real_name = 'Ponder Stibbons'
t.reconnect = true
end
end
it 'sends a message to a recipient' do
expect(@ponder).to receive(:raw).with('PRIVMSG recipient :foo bar baz').once
@ponder.message('recipient', 'foo bar baz')
end
it 'registers with the server' do
expect(@ponder).to receive(:raw).with('NICK Ponder').once
expect(@ponder).to receive(:raw).with('USER Ponder * * :Ponder Stibbons').once
@ponder.register
end
it 'registers with the server with a password' do
@ponder = Ponder::Thaum.new do |t|
t.nick = 'Ponder'
t.username = 'Ponder'
t.real_name = 'Ponder Stibbons'
t.reconnect = true
t.password = 'secret'
end
expect(@ponder).to receive(:raw).with('NICK Ponder').once
expect(@ponder).to receive(:raw).with('USER Ponder * * :Ponder Stibbons').once
expect(@ponder).to receive(:raw).with('PASS secret').once
@ponder.register
end
it 'sends a notice to a recipient' do
expect(@ponder).to receive(:raw).with('NOTICE Ponder :You are cool!').once
@ponder.notice('Ponder', 'You are cool!')
end
it 'sets a mode' do
expect(@ponder).to receive(:raw).with('MODE Ponder +ao').once
@ponder.mode('Ponder', '+ao')
end
it 'kicks an user from a channel' do
expect(@ponder).to receive(:raw).with('KICK #channel Nanny_Ogg').once
@ponder.kick('#channel', 'Nanny_Ogg')
end
it 'kicks an user from a channel with a reason' do
expect(@ponder).to receive(:raw).with('KICK #channel Nanny_Ogg :Go away!').once
@ponder.kick('#channel', 'Nanny_Ogg', 'Go away!')
end
it 'performs an action' do
expect(@ponder).to receive(:raw).with("PRIVMSG #channel :\001ACTION HEX is working!\001").once
@ponder.action('#channel', 'HEX is working!')
end
it 'sets the topic for a channel' do
expect(@ponder).to receive(:raw).with('TOPIC #channel :I like dried frog pills.').once
@ponder.topic('#channel', 'I like dried frog pills.')
end
it 'joins a channel' do
expect(@ponder).to receive(:raw).with('JOIN #channel').once
@ponder.join('#channel')
end
it 'joins a channel with password' do
expect(@ponder).to receive(:raw).with('JOIN #channel secret').once
@ponder.join('#channel', 'secret')
end
it 'parts a channel' do
expect(@ponder).to receive(:raw).with('PART #channel').once
@ponder.part('#channel')
end
it 'parts a channel with a message' do
expect(@ponder).to receive(:raw).with('PART #channel :Partpart').once
@ponder.part('#channel', 'Partpart')
end
it 'quits from the server' do
expect(@ponder).to receive(:raw).with('QUIT').once
expect(@ponder.config.reconnect).to eql(true)
@ponder.quit
expect(@ponder.config.reconnect).to eql(false)
end
it 'quits from the server with a message' do
expect(@ponder).to receive(:raw).with('QUIT :Gone!').once
expect(@ponder.config.reconnect).to eql(true)
@ponder.quit('Gone!')
expect(@ponder.config.reconnect).to eql(false)
end
it 'renames itself' do
expect(@ponder).to receive(:raw).with('NICK :Ridcully').once
@ponder.rename('Ridcully')
end
it 'goes away' do
expect(@ponder).to receive(:raw).with('AWAY').once
@ponder.away
end
it 'goes away with a reason' do
expect(@ponder).to receive(:raw).with('AWAY :At the Mended Drum').once
@ponder.away('At the Mended Drum')
end
it 'comes back from its absence' do
expect(@ponder).to receive(:raw).with('AWAY').twice
@ponder.away
@ponder.back
end
it 'invites an user to a channel' do
expect(@ponder).to receive(:raw).with('INVITE TheLibrarian #mended_drum').once
@ponder.invite('TheLibrarian', '#mended_drum')
end
it 'bans an user from a channel' do
expect(@ponder).to receive(:raw).with('MODE #mended_drum +b foo!bar@baz').once
@ponder.ban('#mended_drum', 'foo!bar@baz')
end
end
|