ircguerilla-irc 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. data/lib/irc/client/command_handler.rb +2 -2
  2. data/lib/irc/client/connected_state.rb +53 -8
  3. data/lib/irc/client/connection.rb +41 -6
  4. data/lib/irc/client/connection_listener.rb +26 -11
  5. data/lib/irc/client/connection_state.rb +15 -2
  6. data/lib/irc/client/context.rb +49 -11
  7. data/lib/irc/client/disconnected_state.rb +28 -16
  8. data/lib/irc/client/message_handler.rb +40 -16
  9. data/lib/irc/client/registered_state.rb +18 -0
  10. data/lib/irc/client/unregistered_state.rb +51 -16
  11. data/lib/irc/commands/nick_command.rb +14 -0
  12. data/lib/irc/messages/error_join_message.rb +1 -1
  13. data/lib/irc/messages/error_message.rb +53 -24
  14. data/lib/irc/messages/error_nick_name_in_use_message.rb +70 -0
  15. data/lib/irc/messages/factory.rb +16 -0
  16. data/lib/irc/messages/isupport_message.rb +86 -0
  17. data/lib/irc/messages/kick_message.rb +114 -0
  18. data/lib/irc/messages/message.rb +21 -1
  19. data/lib/irc/messages/nick_message.rb +17 -2
  20. data/lib/irc/messages/pong_message.rb +1 -1
  21. data/lib/irc/messages/welcome_message.rb +72 -0
  22. data/lib/irc/util/color.rb +77 -0
  23. data/lib/irc/util/nick_generator.rb +58 -0
  24. data/test/functional/irc/client/connection_test.rb +34 -1
  25. data/test/functional/irc/client/context_test.rb +5 -2
  26. data/test/mocks/test/irc/client/connection.rb +128 -0
  27. data/test/mocks/test/irc/client/disconnected_state.rb +44 -0
  28. data/test/test_helper.rb +1 -1
  29. data/test/unit/irc/client/command_handler_test.rb +12 -12
  30. data/test/unit/irc/client/message_handler_test.rb +136 -0
  31. data/test/unit/irc/commands/command_test.rb +87 -84
  32. data/test/unit/irc/commands/join_command_test.rb +3 -1
  33. data/test/unit/irc/commands/nick_command_test.rb +7 -1
  34. data/test/unit/irc/commands/ping_command_test.rb +12 -16
  35. data/test/unit/irc/commands/pong_command_test.rb +2 -1
  36. data/test/unit/irc/messages/error_join_message_test.rb +23 -2
  37. data/test/unit/irc/messages/error_message_test.rb +56 -0
  38. data/test/unit/irc/messages/error_nick_name_in_use_message_test.rb +56 -0
  39. data/test/unit/irc/messages/factory_test.rb +25 -0
  40. data/test/unit/irc/messages/isupport_message_test.rb +138 -0
  41. data/test/unit/irc/messages/join_message_test.rb +22 -1
  42. data/test/unit/irc/messages/kick_message_test.rb +76 -0
  43. data/test/unit/irc/messages/message_test.rb +33 -0
  44. data/test/unit/irc/messages/nick_message_test.rb +22 -1
  45. data/test/unit/irc/messages/notice_message_test.rb +22 -1
  46. data/test/unit/irc/messages/part_message_test.rb +22 -1
  47. data/test/unit/irc/messages/ping_message_test.rb +21 -1
  48. data/test/unit/irc/messages/pong_message_test.rb +21 -1
  49. data/test/unit/irc/messages/private_message_test.rb +22 -1
  50. data/test/unit/irc/messages/welcome_message_test.rb +59 -0
  51. data/test/unit/irc/util/color_test.rb +97 -0
  52. data/test/unit/irc/util/nick_generator_test.rb +52 -0
  53. metadata +69 -52
@@ -28,10 +28,30 @@ require 'test/unit'
28
28
 
29
29
  class IRC::Messages::FactoryTest < Test::Unit::TestCase
30
30
 
31
+ def test_error_message
32
+ message = IRC::Messages::Factory.create("ERROR :Closing Link: 85.178.111.249 (*** Banned (cache))")
33
+ assert message.instance_of?(IRC::Messages::ErrorMessage)
34
+ end
35
+
36
+ def test_error_nick_name_in_use_message
37
+ message = IRC::Messages::Factory.create(":irc.easynews.com 433 * fumanshu :Nickname is already in use.")
38
+ assert message.instance_of?(IRC::Messages::ErrorNickNameInUseMessage)
39
+ end
40
+
41
+ def test_isupport_message
42
+ message = IRC::Messages::ISupportMessage.new(":irc.efnet.pl 005 fumanshu STD=i-d STATUSMSG=@+ KNOCK EXCEPTS INVEX MODES=4 MAXCHANNELS=25 MAXBANS=100 MAXTARGET S=4 NICKLEN=9 TOPICLEN=120 KICKLEN=120 :are supported by this server")
43
+ assert message.instance_of?(IRC::Messages::ISupportMessage)
44
+ end
45
+
31
46
  def test_join_message
32
47
  message = IRC::Messages::Factory.create(":WiZ JOIN #Twilight_zone")
33
48
  assert message.instance_of?(IRC::Messages::JoinMessage)
34
49
  end
50
+
51
+ def test_kick_message
52
+ message = IRC::Messages::Factory.create(":WiZ KICK #Finnish John")
53
+ assert message.instance_of?(IRC::Messages::KickMessage)
54
+ end
35
55
 
36
56
  def test_nick_message
37
57
  message = IRC::Messages::Factory.create(":WiZ NICK Kilroy")
@@ -62,5 +82,10 @@ class IRC::Messages::FactoryTest < Test::Unit::TestCase
62
82
  message = IRC::Messages::Factory.create(":Angel PRIVMSG Wiz :Hello are you receiving this message ?")
63
83
  assert message.instance_of?(IRC::Messages::PrivateMessage)
64
84
  end
85
+
86
+ def test_welcome_message
87
+ message = IRC::Messages::Factory.create(":irc.easynews.com 001 fumanshu :Welcome to the EFNet IRC via Easynews fumanshu")
88
+ assert message.instance_of?(IRC::Messages::WelcomeMessage)
89
+ end
65
90
 
66
91
  end
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #
24
+ # $Id$
25
+ #
26
+ require 'irc/messages/invalid_message'
27
+ require 'irc/messages/isupport_message'
28
+ require 'irc/messages/message_test'
29
+ require 'test/unit'
30
+
31
+ class IRC::Messages::ISupportMessageTest < IRC::Messages::MessageTest
32
+
33
+ def test_isupport
34
+
35
+ # First isupport message.
36
+ message = IRC::Messages::ISupportMessage.new(":irc.efnet.pl 005 fumanshu STD=i-d STATUSMSG=@+ KNOCK EXCEPTS INVEX MODES=4 MAXCHANNELS=25 MAXBANS=100 MAXTARGET S=4 NICKLEN=9 TOPICLEN=120 KICKLEN=120 :are supported by this server")
37
+
38
+ # Verify the standard message fields.
39
+ assert_equal "irc.efnet.pl", message.server
40
+ assert_equal 5, message.code
41
+ assert_equal "fumanshu", message.nick
42
+
43
+ # Verify the supported options.
44
+ assert_equal "i-d", message.options["STD"]
45
+ assert_equal "@+", message.options["STATUSMSG"]
46
+ assert message.options.has_key?("KNOCK")
47
+ assert message.options.has_key?("EXCEPTS")
48
+ assert message.options.has_key?("INVEX")
49
+ assert_equal 4, message.options["MODES"]
50
+ assert_equal 25, message.options["MAXCHANNELS"]
51
+ assert_equal 100, message.options["MAXBANS"]
52
+ assert_equal 4, message.options["S"]
53
+ assert_equal 9, message.options["NICKLEN"]
54
+ assert_equal 120, message.options["TOPICLEN"]
55
+ assert_equal 120, message.options["KICKLEN"]
56
+
57
+ # Second isupport message.
58
+ message = IRC::Messages::ISupportMessage.new(":irc.efnet.pl 005 fumanshu CHANTYPES=#& PREFIX=(ov)@+ CHANMODES=eIb,k,l,imnpst NETWORK=EFNet CASEMAPPING=rfc1459 CHARSET=ascii CALLERID ETRACE WALLCHOPS SAFELIST ELIST=U :are supported by this server")
59
+
60
+ # Verify the standard message fields.
61
+ assert_equal "irc.efnet.pl", message.server
62
+ assert_equal 5, message.code
63
+ assert_equal "fumanshu", message.nick
64
+
65
+ # Verify the supported options from the second message.
66
+ assert_equal "#&", message.options["CHANTYPES"]
67
+ assert_equal "(ov)@+", message.options["PREFIX"]
68
+ assert_equal "eIb,k,l,imnpst", message.options["CHANMODES"]
69
+ assert_equal "EFNet", message.options["NETWORK"]
70
+ assert_equal "rfc1459", message.options["CASEMAPPING"]
71
+ assert_equal "ascii", message.options["CHARSET"]
72
+ assert message.options.has_key?("CALLERID")
73
+ assert message.options.has_key?("ETRACE")
74
+ assert message.options.has_key?("WALLCHOPS")
75
+ assert message.options.has_key?("SAFELIST")
76
+ assert_equal "U", message.options["ELIST"]
77
+
78
+ end
79
+
80
+ def test_handle
81
+
82
+ # Simulate a connection registration.
83
+ connection.add_connection_listener(self)
84
+ connection.connect(server)
85
+ connection.register
86
+
87
+ # First isupport message.
88
+ message = IRC::Messages::ISupportMessage.new(":irc.efnet.pl 005 fumanshu STD=i-d STATUSMSG=@+ KNOCK EXCEPTS INVEX MODES=4 MAXCHANNELS=25 MAXBANS=100 MAXTARGET S=4 NICKLEN=9 TOPICLEN=120 KICKLEN=120 :are supported by this server")
89
+ message.handle(connection.context)
90
+
91
+ # Verify the supported options.
92
+ assert_equal "i-d", connection.context.options["STD"]
93
+ assert_equal "@+", connection.context.options["STATUSMSG"]
94
+ assert connection.context.options.has_key?("KNOCK")
95
+ assert connection.context.options.has_key?("EXCEPTS")
96
+ assert connection.context.options.has_key?("INVEX")
97
+ assert_equal 4, connection.context.options["MODES"]
98
+ assert_equal 25, connection.context.options["MAXCHANNELS"]
99
+ assert_equal 100, connection.context.options["MAXBANS"]
100
+ assert_equal 4, connection.context.options["S"]
101
+ assert_equal 9, connection.context.options["NICKLEN"]
102
+ assert_equal 120, connection.context.options["TOPICLEN"]
103
+ assert_equal 120, connection.context.options["KICKLEN"]
104
+
105
+ # Second isupport message.
106
+ message = IRC::Messages::ISupportMessage.new(":irc.efnet.pl 005 fumanshu CHANTYPES=#& PREFIX=(ov)@+ CHANMODES=eIb,k,l,imnpst NETWORK=EFNet CASEMAPPING=rfc1459 CHARSET=ascii CALLERID ETRACE WALLCHOPS SAFELIST ELIST=U :are supported by this server")
107
+ message.handle(connection.context)
108
+
109
+ # Verify the supported options from the first message.
110
+ assert_equal "i-d", connection.context.options["STD"]
111
+ assert_equal "@+", connection.context.options["STATUSMSG"]
112
+ assert connection.context.options.has_key?("KNOCK")
113
+ assert connection.context.options.has_key?("EXCEPTS")
114
+ assert connection.context.options.has_key?("INVEX")
115
+ assert_equal 4, connection.context.options["MODES"]
116
+ assert_equal 25, connection.context.options["MAXCHANNELS"]
117
+ assert_equal 100, connection.context.options["MAXBANS"]
118
+ assert_equal 4, connection.context.options["S"]
119
+ assert_equal 9, connection.context.options["NICKLEN"]
120
+ assert_equal 120, connection.context.options["TOPICLEN"]
121
+ assert_equal 120, connection.context.options["KICKLEN"]
122
+
123
+ # Verify the supported options from the second message.
124
+ assert_equal "#&", connection.context.options["CHANTYPES"]
125
+ assert_equal "(ov)@+", connection.context.options["PREFIX"]
126
+ assert_equal "eIb,k,l,imnpst", connection.context.options["CHANMODES"]
127
+ assert_equal "EFNet", connection.context.options["NETWORK"]
128
+ assert_equal "rfc1459", connection.context.options["CASEMAPPING"]
129
+ assert_equal "ascii", connection.context.options["CHARSET"]
130
+ assert connection.context.options.has_key?("CALLERID")
131
+ assert connection.context.options.has_key?("ETRACE")
132
+ assert connection.context.options.has_key?("WALLCHOPS")
133
+ assert connection.context.options.has_key?("SAFELIST")
134
+ assert_equal "U", connection.context.options["ELIST"]
135
+
136
+ end
137
+
138
+ end
@@ -25,9 +25,15 @@
25
25
  #
26
26
  require 'irc/messages/invalid_message'
27
27
  require 'irc/messages/join_message'
28
+ require 'irc/messages/message_test'
28
29
  require 'test/unit'
29
30
 
30
- class IRC::Messages::JoinMessageTest < Test::Unit::TestCase
31
+ class IRC::Messages::JoinMessageTest < IRC::Messages::MessageTest
32
+
33
+ # This method gets called when a user (possibly us) joins a channel.
34
+ def on_join(connection, channel, user)
35
+ @connection, @channel, @user = connection, channel, user
36
+ end
31
37
 
32
38
  def test_join
33
39
 
@@ -43,4 +49,19 @@ class IRC::Messages::JoinMessageTest < Test::Unit::TestCase
43
49
 
44
50
  end
45
51
 
52
+ def test_handle
53
+
54
+ # Simulate a connection registration.
55
+ connection.add_connection_listener(self)
56
+ connection.connect(server)
57
+ connection.register
58
+
59
+ message = IRC::Messages::JoinMessage.new(":fumanshu!0NFOHVOw@e178069051.adsl.alicedsl.de JOIN :#ircguerilla")
60
+ message.handle(connection.context)
61
+
62
+ assert_equal "#ircguerilla", @channel.name
63
+ assert_equal "fumanshu", @user.nick
64
+
65
+ end
66
+
46
67
  end
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #
24
+ # $Id$
25
+ #
26
+ require 'irc/messages/invalid_message'
27
+ require 'irc/messages/kick_message'
28
+ require 'irc/messages/message_test'
29
+ require 'test/unit'
30
+
31
+ class IRC::Messages::KickMessageTest < IRC::Messages::MessageTest
32
+
33
+ # This method gets called when a user gets kicked from a channel.
34
+ def on_kick(connection, channel, kicker_user, kicked_user, reason)
35
+ @connection, @channel, @kicker_user, @kicked_user, @reason = connection, channel, kicker_user, kicked_user, reason
36
+ # puts channel.class
37
+ end
38
+
39
+ def test_join
40
+
41
+ message = IRC::Messages::KickMessage.new(":vacant!hollow@64.18.146.82 KICK #dnbarena fumanshu :Drone")
42
+ assert_equal "vacant", message.nick
43
+ assert_equal "hollow", message.login
44
+ assert_equal "64.18.146.82", message.host
45
+ assert_equal "fumanshu", message.kicked
46
+ assert_equal "vacant", message.kicker
47
+ assert_equal "Drone", message.reason
48
+
49
+ message = IRC::Messages::KickMessage.new(":WiZ KICK #Finnish John")
50
+ assert_equal "WiZ", message.nick
51
+ assert_nil message.login
52
+ assert_nil message.host
53
+ assert_equal "John", message.kicked
54
+ assert_equal "WiZ", message.kicker
55
+ assert_nil message.reason
56
+
57
+ end
58
+
59
+ def test_handle
60
+
61
+ # Simulate a connection registration.
62
+ connection.add_connection_listener(self)
63
+ connection.connect(server)
64
+ connection.register
65
+
66
+ message = IRC::Messages::KickMessage.new(":vacant!hollow@64.18.146.82 KICK #dnbarena fumanshu :Drone")
67
+ message.handle(connection.context)
68
+
69
+ assert_equal "#dnbarena", @channel.name
70
+ assert_equal "vacant", @kicker_user.nick
71
+ assert_equal "fumanshu", @kicked_user.nick
72
+ assert_equal "Drone", @reason
73
+
74
+ end
75
+
76
+ end
@@ -23,11 +23,44 @@
23
23
  #
24
24
  # $Id: message_test.rb 93 2006-08-13 21:30:53Z roman $
25
25
  #
26
+ require 'irc/client/connection'
27
+ require 'irc/client/connection_listener'
28
+ require 'irc/client/context'
29
+ require 'irc/messages/message'
30
+ require 'irc/models/network'
26
31
  require 'irc/messages/message'
27
32
  require 'test/unit'
33
+ require File.dirname(__FILE__) + '/../../../test_helper'
28
34
 
29
35
  class IRC::Messages::MessageTest < Test::Unit::TestCase
30
36
 
37
+ include IRC::Client::ConnectionListener
38
+
39
+ attr_reader :connection
40
+ attr_reader :server
41
+
42
+ def setup
43
+
44
+ # The connection mock & the server.
45
+ @connection = IRC::Client::Connection.new
46
+ @server = IRC::Models::Network.new(:name => "Efnet").create_server("irc.efnet.pl")
47
+
48
+ end
49
+
50
+ def test_eql
51
+
52
+ message1 = IRC::Messages::Message.new(":WiZ JOIN #Twilight_zone")
53
+ message2 = IRC::Messages::Message.new(":WiZ JOIN #Twilight_zone")
54
+
55
+ assert_equal message1, message1
56
+ assert_equal message1, message2
57
+
58
+ message3 = IRC::Messages::Message.new(":WiZ JOIN #ircguerilla")
59
+ assert_not_equal message1, message3
60
+ assert_not_equal message2, message3
61
+
62
+ end
63
+
31
64
  def test_join_message
32
65
 
33
66
  message = IRC::Messages::JoinMessage.new(":WiZ JOIN #Twilight_zone")
@@ -24,10 +24,16 @@
24
24
  # $Id: nick_message_test.rb 89 2006-08-13 14:03:35Z roman $
25
25
  #
26
26
  require 'irc/messages/invalid_message'
27
+ require 'irc/messages/message_test'
27
28
  require 'irc/messages/nick_message'
28
29
  require 'test/unit'
29
30
 
30
- class IRC::Messages::NickMessageTest < Test::Unit::TestCase
31
+ class IRC::Messages::NickMessageTest < IRC::Messages::MessageTest
32
+
33
+ # This method gets called when a user changes it's nick name.
34
+ def on_nick(connection, before, after)
35
+ @before, @after = before, after
36
+ end
31
37
 
32
38
  def test_invalid_messages
33
39
 
@@ -45,4 +51,19 @@ class IRC::Messages::NickMessageTest < Test::Unit::TestCase
45
51
  assert_equal "WiZ", message.before
46
52
  end
47
53
 
54
+ def test_handle
55
+
56
+ # Simulate a connection registration.
57
+ connection.add_connection_listener(self)
58
+ connection.connect(server)
59
+ connection.register
60
+
61
+ message = IRC::Messages::NickMessage.new(":WiZ NICK Kilroy")
62
+ message.handle(connection.context)
63
+
64
+ assert_equal "WiZ", @before.nick
65
+ assert_equal "Kilroy", @after.nick
66
+
67
+ end
68
+
48
69
  end
@@ -25,9 +25,15 @@
25
25
  #
26
26
  require 'irc/messages/invalid_message'
27
27
  require 'irc/messages/notice_message'
28
+ require 'irc/messages/message_test'
28
29
  require 'test/unit'
29
30
 
30
- class IRC::Messages::NoticeMessageTest < Test::Unit::TestCase
31
+ class IRC::Messages::NoticeMessageTest < IRC::Messages::MessageTest
32
+
33
+ # This method gets called when a notice message was received.
34
+ def on_notice(connection, user, message)
35
+ @user, @message = user, message
36
+ end
31
37
 
32
38
  def test_invalid_messages
33
39
  assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::NoticeMessage.new("") }
@@ -40,4 +46,19 @@ class IRC::Messages::NoticeMessageTest < Test::Unit::TestCase
40
46
  assert_equal "*** Looking up your hostname...", message.message
41
47
  end
42
48
 
49
+ def test_handle
50
+
51
+ # Simulate a connection registration.
52
+ connection.add_connection_listener(self)
53
+ connection.connect(server)
54
+ connection.register
55
+
56
+ message = IRC::Messages::NoticeMessage.new("NOTICE AUTH :*** Looking up your hostname...")
57
+ message.handle(connection.context)
58
+
59
+ assert_equal "AUTH", @user.nick
60
+ assert_equal "*** Looking up your hostname...", @message
61
+
62
+ end
63
+
43
64
  end
@@ -26,10 +26,16 @@
26
26
  #
27
27
  require 'irc/messages/invalid_message'
28
28
  require 'irc/messages/join_message'
29
+ require 'irc/messages/message_test'
29
30
  require 'test/unit'
30
31
 
31
- class IRC::Messages::PartMessageTest < Test::Unit::TestCase
32
+ class IRC::Messages::PartMessageTest < IRC::Messages::MessageTest
32
33
 
34
+ # This method gets called when a user (possibly us) leaves a channel.
35
+ def on_part(connection, channel, user)
36
+ @channel, @user = channel, user
37
+ end
38
+
33
39
  def test_part
34
40
 
35
41
  message = IRC::Messages::PartMessage.new(":WiZ PART #Twilight_zone")
@@ -44,4 +50,19 @@ class IRC::Messages::PartMessageTest < Test::Unit::TestCase
44
50
 
45
51
  end
46
52
 
53
+ def test_handle
54
+
55
+ # Simulate a connection registration.
56
+ connection.add_connection_listener(self)
57
+ connection.connect(server)
58
+ connection.register
59
+
60
+ message = IRC::Messages::PartMessage.new(":fumanshu!g3jE7XnP@e178069051.adsl.alicedsl.de PART #ircguerilla")
61
+ message.handle(connection.context)
62
+
63
+ assert_equal "#ircguerilla", @channel.name
64
+ assert_equal "fumanshu", @user.nick
65
+
66
+ end
67
+
47
68
  end