ircguerilla-irc 1.1.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 (69) hide show
  1. data/lib/irc/client/client_error.rb +35 -0
  2. data/lib/irc/client/command_handler.rb +113 -0
  3. data/lib/irc/client/connected_state.rb +95 -0
  4. data/lib/irc/client/connection.rb +119 -0
  5. data/lib/irc/client/connection_listener.rb +97 -0
  6. data/lib/irc/client/connection_state.rb +88 -0
  7. data/lib/irc/client/context.rb +250 -0
  8. data/lib/irc/client/disconnected_state.rb +132 -0
  9. data/lib/irc/client/message_handler.rb +87 -0
  10. data/lib/irc/client/registered_state.rb +90 -0
  11. data/lib/irc/client/unregistered_state.rb +113 -0
  12. data/lib/irc/commands/command.rb +57 -0
  13. data/lib/irc/commands/invalid_command.rb +35 -0
  14. data/lib/irc/commands/join_command.rb +122 -0
  15. data/lib/irc/commands/nick_command.rb +86 -0
  16. data/lib/irc/commands/part_command.rb +84 -0
  17. data/lib/irc/commands/password_command.rb +72 -0
  18. data/lib/irc/commands/ping_command.rb +79 -0
  19. data/lib/irc/commands/pong_command.rb +68 -0
  20. data/lib/irc/commands/quit_command.rb +77 -0
  21. data/lib/irc/commands/user_command.rb +105 -0
  22. data/lib/irc/messages/codes.rb +186 -0
  23. data/lib/irc/messages/error_join_message.rb +72 -0
  24. data/lib/irc/messages/error_message.rb +101 -0
  25. data/lib/irc/messages/factory.rb +122 -0
  26. data/lib/irc/messages/invalid_message.rb +35 -0
  27. data/lib/irc/messages/join_message.rb +130 -0
  28. data/lib/irc/messages/message.rb +110 -0
  29. data/lib/irc/messages/nick_message.rb +93 -0
  30. data/lib/irc/messages/notice_message.rb +87 -0
  31. data/lib/irc/messages/part_message.rb +95 -0
  32. data/lib/irc/messages/ping_message.rb +101 -0
  33. data/lib/irc/messages/pong_message.rb +89 -0
  34. data/lib/irc/messages/private_message.rb +121 -0
  35. data/lib/irc/models/bot.rb +159 -0
  36. data/lib/irc/models/channel.rb +158 -0
  37. data/lib/irc/models/network.rb +252 -0
  38. data/lib/irc/models/packet.rb +84 -0
  39. data/lib/irc/models/server.rb +116 -0
  40. data/lib/irc/models/user.rb +112 -0
  41. data/test/functional/irc/client/connection_test.rb +118 -0
  42. data/test/functional/irc/client/context_test.rb +126 -0
  43. data/test/test_helper.rb +32 -0
  44. data/test/unit/irc/client/command_handler_test.rb +137 -0
  45. data/test/unit/irc/commands/join_command_test.rb +72 -0
  46. data/test/unit/irc/commands/nick_command_test.rb +35 -0
  47. data/test/unit/irc/commands/part_command_test.rb +52 -0
  48. data/test/unit/irc/commands/password_command_test.rb +35 -0
  49. data/test/unit/irc/commands/ping_command_test.rb +36 -0
  50. data/test/unit/irc/commands/pong_command_test.rb +36 -0
  51. data/test/unit/irc/commands/quit_command_test.rb +35 -0
  52. data/test/unit/irc/commands/user_command_test.rb +35 -0
  53. data/test/unit/irc/messages/error_join_message_test.rb +45 -0
  54. data/test/unit/irc/messages/factory_test.rb +62 -0
  55. data/test/unit/irc/messages/join_message_test.rb +46 -0
  56. data/test/unit/irc/messages/message_test.rb +56 -0
  57. data/test/unit/irc/messages/nick_message_test.rb +48 -0
  58. data/test/unit/irc/messages/notice_message_test.rb +43 -0
  59. data/test/unit/irc/messages/part_message_test.rb +47 -0
  60. data/test/unit/irc/messages/ping_message_test.rb +57 -0
  61. data/test/unit/irc/messages/pong_message_test.rb +57 -0
  62. data/test/unit/irc/messages/private_message_test.rb +42 -0
  63. data/test/unit/irc/models/bot_test.rb +85 -0
  64. data/test/unit/irc/models/channel_test.rb +90 -0
  65. data/test/unit/irc/models/network_test.rb +210 -0
  66. data/test/unit/irc/models/packet_test.rb +38 -0
  67. data/test/unit/irc/models/server_test.rb +54 -0
  68. data/test/unit/irc/models/user_test.rb +67 -0
  69. metadata +111 -0
@@ -0,0 +1,35 @@
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: quit_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/quit_command'
27
+ require 'test/unit'
28
+
29
+ class IRC::Commands::QuitCommandTest < Test::Unit::TestCase
30
+
31
+ def test_command
32
+ assert_equal "QUIT :Good bye", IRC::Commands::QuitCommand.new("Good bye").command
33
+ end
34
+
35
+ end
@@ -0,0 +1,35 @@
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: user_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/user_command'
27
+ require 'test/unit'
28
+
29
+ class IRC::Commands::UserCommandTest < Test::Unit::TestCase
30
+
31
+ def test_command
32
+ assert_equal "USER fumanshu localhost irc.efnet.pl :Dr. Fumanshu", IRC::Commands::UserCommand.new("fumanshu", "localhost", "irc.efnet.pl", "Dr. Fumanshu").command
33
+ end
34
+
35
+ end
@@ -0,0 +1,45 @@
1
+
2
+ #!/usr/bin/env ruby
3
+ #
4
+ # Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+ # $Id$
26
+ #
27
+ require 'irc/messages/invalid_message'
28
+ require 'irc/messages/error_join_message'
29
+ require 'test/unit'
30
+
31
+ class IRC::Messages::ErrorJoinMessageTest < Test::Unit::TestCase
32
+
33
+
34
+ def test_error_no_such_channel
35
+
36
+ message = IRC::Messages::ErrorJoinMessage.new(":irc.easynews.com 403 fumanshu invalid :No such channel")
37
+ assert_equal "irc.easynews.com", message.server
38
+ assert_equal 403, message.code
39
+ assert_equal "fumanshu", message.nick
40
+ assert_equal "invalid", message.channel
41
+ assert_equal "No such channel", message.reason
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,62 @@
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: factory_test.rb 90 2006-08-13 14:45:04Z roman $
25
+ #
26
+ require 'irc/messages/factory'
27
+ require 'test/unit'
28
+
29
+ class IRC::Messages::FactoryTest < Test::Unit::TestCase
30
+
31
+ def test_join_message
32
+ message = IRC::Messages::Factory.create(":WiZ JOIN #Twilight_zone")
33
+ assert message.instance_of?(IRC::Messages::JoinMessage)
34
+ end
35
+
36
+ def test_nick_message
37
+ message = IRC::Messages::Factory.create(":WiZ NICK Kilroy")
38
+ assert message.instance_of?(IRC::Messages::NickMessage)
39
+ end
40
+
41
+ def test_notice_message
42
+ message = IRC::Messages::Factory.create("NOTICE AUTH :*** Looking up your hostname...")
43
+ assert message.instance_of?(IRC::Messages::NoticeMessage)
44
+ end
45
+
46
+ def test_part_message
47
+ message = IRC::Messages::Factory.create(":WiZ PART #Twilight_zone")
48
+ assert message.instance_of?(IRC::Messages::PartMessage)
49
+ end
50
+
51
+ def test_ping_message
52
+ message = IRC::Messages::Factory.create("PING tolsun.oulu.fi")
53
+ assert message.instance_of?(IRC::Messages::PingMessage)
54
+ end
55
+
56
+ def test_pong_message
57
+ message = IRC::Messages::Factory.create("PONG tolsun.oulu.fi")
58
+ assert message.instance_of?(IRC::Messages::PongMessage)
59
+ end
60
+
61
+
62
+ end
@@ -0,0 +1,46 @@
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/join_message'
28
+ require 'test/unit'
29
+
30
+ class IRC::Messages::JoinMessageTest < Test::Unit::TestCase
31
+
32
+ def test_join
33
+
34
+ message = IRC::Messages::JoinMessage.new(":WiZ JOIN #Twilight_zone")
35
+ assert_equal "WiZ", message.nick
36
+ assert_equal "#Twilight_zone", message.channel
37
+
38
+ message = IRC::Messages::JoinMessage.new(":fumanshu!0NFOHVOw@e178069051.adsl.alicedsl.de JOIN :#ircguerilla")
39
+ assert_equal "fumanshu", message.nick
40
+ assert_equal "0NFOHVOw", message.login
41
+ assert_equal "e178069051.adsl.alicedsl.de", message.host
42
+ assert_equal "#ircguerilla", message.channel
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,56 @@
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: message_test.rb 93 2006-08-13 21:30:53Z roman $
25
+ #
26
+ require 'irc/messages/message'
27
+ require 'test/unit'
28
+
29
+ class IRC::Messages::MessageTest < Test::Unit::TestCase
30
+
31
+ def test_join_message
32
+
33
+ message = IRC::Messages::JoinMessage.new(":WiZ JOIN #Twilight_zone")
34
+ assert_equal "WiZ", message.nick
35
+ assert_equal "WiZ", message.server
36
+ assert_equal "JOIN", message.code
37
+ assert_equal "#Twilight_zone", message.message
38
+
39
+ message = IRC::Messages::Message.new(":fumanshu!0NFOHVOw@e178069051.adsl.alicedsl.de JOIN :#ircguerilla")
40
+ assert_equal "JOIN", message.code
41
+ assert_nil message.server
42
+ assert_equal "fumanshu", message.nick
43
+ assert_equal "0NFOHVOw", message.login
44
+ assert_equal "e178069051.adsl.alicedsl.de", message.host
45
+ assert_equal ":#ircguerilla", message.message
46
+
47
+ end
48
+
49
+ def test_welcome_message
50
+ message = IRC::Messages::Message.new(":localhost.localdomain 001 drfumansh :Welcome to the Internet Relay Network, drfumansh")
51
+ assert_equal 1, message.code
52
+ assert_equal "localhost.localdomain", message.server
53
+ assert_equal "drfumansh :Welcome to the Internet Relay Network, drfumansh", message.message
54
+ end
55
+
56
+ end
@@ -0,0 +1,48 @@
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: nick_message_test.rb 89 2006-08-13 14:03:35Z roman $
25
+ #
26
+ require 'irc/messages/invalid_message'
27
+ require 'irc/messages/nick_message'
28
+ require 'test/unit'
29
+
30
+ class IRC::Messages::NickMessageTest < Test::Unit::TestCase
31
+
32
+ def test_invalid_messages
33
+
34
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::NickMessage.new("") }
35
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::NickMessage.new("NICK") }
36
+
37
+ # This is a command, not a message!
38
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::NickMessage.new("NICK Kilroy") }
39
+
40
+ end
41
+
42
+ def test_nick_change
43
+ message = IRC::Messages::NickMessage.new(":WiZ NICK Kilroy")
44
+ assert_equal "Kilroy", message.after
45
+ assert_equal "WiZ", message.before
46
+ end
47
+
48
+ end
@@ -0,0 +1,43 @@
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: nick_message_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/messages/invalid_message'
27
+ require 'irc/messages/notice_message'
28
+ require 'test/unit'
29
+
30
+ class IRC::Messages::NoticeMessageTest < Test::Unit::TestCase
31
+
32
+ def test_invalid_messages
33
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::NoticeMessage.new("") }
34
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::NoticeMessage.new("NOTICE") }
35
+ end
36
+
37
+ def test_notice
38
+ message = IRC::Messages::NoticeMessage.new("NOTICE AUTH :*** Looking up your hostname...")
39
+ assert_equal "AUTH", message.nick
40
+ assert_equal "*** Looking up your hostname...", message.message
41
+ end
42
+
43
+ end
@@ -0,0 +1,47 @@
1
+
2
+ #!/usr/bin/env ruby
3
+ #
4
+ # Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+ # $Id$
26
+ #
27
+ require 'irc/messages/invalid_message'
28
+ require 'irc/messages/join_message'
29
+ require 'test/unit'
30
+
31
+ class IRC::Messages::PartMessageTest < Test::Unit::TestCase
32
+
33
+ def test_part
34
+
35
+ message = IRC::Messages::PartMessage.new(":WiZ PART #Twilight_zone")
36
+ assert_equal "WiZ", message.nick
37
+ assert_equal "#Twilight_zone", message.channel
38
+
39
+ message = IRC::Messages::PartMessage.new(":fumanshu!g3jE7XnP@e178069051.adsl.alicedsl.de PART #ircguerilla")
40
+ assert_equal "fumanshu", message.nick
41
+ assert_equal "g3jE7XnP", message.login
42
+ assert_equal "e178069051.adsl.alicedsl.de", message.host
43
+ assert_equal "#ircguerilla", message.channel
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,57 @@
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: ping_message_test.rb 93 2006-08-13 21:30:53Z roman $
25
+ #
26
+ require 'irc/messages/invalid_message'
27
+ require 'irc/messages/ping_message'
28
+ require 'test/unit'
29
+
30
+ class IRC::Messages::PingMessageTest < Test::Unit::TestCase
31
+
32
+ def test_invalid_messages
33
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::PingMessage.new("") }
34
+ assert_raise(IRC::Messages::InvalidMessage) { IRC::Messages::PingMessage.new("PING") }
35
+ end
36
+
37
+ def test_server
38
+
39
+ message = IRC::Messages::PingMessage.new("PING tolsun.oulu.fi")
40
+ assert_equal ["tolsun.oulu.fi"], message.servers
41
+
42
+ message = IRC::Messages::PingMessage.new("PING :302757EC")
43
+ assert_equal ["302757EC"], message.servers
44
+
45
+ end
46
+
47
+ def test_servers
48
+
49
+ message = IRC::Messages::PingMessage.new("PING tolsun.oulu.fi irc.efnet.pl")
50
+ assert_equal ["tolsun.oulu.fi", "irc.efnet.pl"], message.servers
51
+
52
+ message = IRC::Messages::PingMessage.new("PING :tolsun.oulu.fi :irc.efnet.pl")
53
+ assert_equal ["tolsun.oulu.fi", "irc.efnet.pl"], message.servers
54
+
55
+ end
56
+
57
+ end