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,32 @@
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: test_helper.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'log4r/configurator'
27
+
28
+ class Test::Unit::TestCase
29
+
30
+ Log4r::Configurator.load_xml_file(File.dirname(__FILE__) + '/log4r.xml')
31
+
32
+ end
@@ -0,0 +1,137 @@
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/client/command_handler'
27
+ require 'irc/client/context'
28
+ require 'irc/commands/nick_command'
29
+ require 'irc/commands/password_command'
30
+ require 'irc/models/network'
31
+ require 'stringio'
32
+ require 'test/unit'
33
+
34
+ class IRC::Client::CommandHandlerTest < Test::Unit::TestCase
35
+
36
+ def setup
37
+
38
+ # Set up a connection context.
39
+ @context = IRC::Client::Connection::Context.new
40
+ @context.network = IRC::Models::Network.new(:name => "Efnet")
41
+ @context.socket = StringIO.new("", "w+")
42
+
43
+ # Initialize the command handler with the mock connection context.
44
+ @command_handler = IRC::Client::CommandHandler.new(@context)
45
+ @command_handler.delay = 0.1
46
+
47
+ end
48
+
49
+ def test_start
50
+
51
+ # Start the command handler.
52
+ @command_handler.start
53
+
54
+ # Starting the command handler again should raise an exception.
55
+ assert_raise(IRC::Client::CommandHandlerError) { @command_handler.start }
56
+
57
+ # Stop the command handler.
58
+ @command_handler.stop
59
+
60
+ end
61
+
62
+ def test_stop
63
+
64
+ # Stopping a not started command handler should raise an exception.
65
+ assert_raise(IRC::Client::CommandHandlerError) { @command_handler.stop }
66
+
67
+ # Stopping a command handler after it was started should work fine.
68
+ @command_handler.start
69
+ @command_handler.stop
70
+
71
+ end
72
+
73
+ def test_send_command
74
+
75
+ # Start the command handler.
76
+ @command_handler.start
77
+
78
+ # Send the password command.
79
+ password_command = IRC::Commands::PasswordCommand.new("secret")
80
+ @command_handler.send_command(password_command)
81
+
82
+ # Send the nick command.
83
+ nick_command = IRC::Commands::NickCommand.new("fumanshu")
84
+ @command_handler.send_command(nick_command)
85
+
86
+ # Rewind the stringio object, so we can read from it.
87
+ @context.socket.rewind
88
+
89
+ # Both commands should be available immediately, since they were not sent through the queue.
90
+ assert_equal password_command.command, @context.socket.readline.chomp
91
+ assert_equal nick_command.command, @context.socket.readline.chomp
92
+
93
+ # There should be no more commands available.
94
+ assert_raise(EOFError) { @context.socket.readline }
95
+
96
+ # Stop the command handler.
97
+ @command_handler.stop
98
+
99
+ end
100
+
101
+ def test_send_command_via_queue
102
+
103
+ # Start the command handler.
104
+ @command_handler.start
105
+
106
+ # Send the password command.
107
+ password_command = IRC::Commands::PasswordCommand.new("secret")
108
+ @command_handler.send_command_via_queue(password_command)
109
+
110
+ # Send the nick command.
111
+ nick_command = IRC::Commands::NickCommand.new("fumanshu")
112
+ @command_handler << nick_command
113
+
114
+ # Rewind the stringio object, so we can read from it.
115
+ @context.socket.rewind
116
+
117
+ # The first command got sent but the second is still in the queue.
118
+ assert_equal password_command.command, @context.socket.readline.chomp
119
+ assert_raise(EOFError) { @context.socket.readline }
120
+
121
+ # Wait for the 2nd command.
122
+ sleep @command_handler.delay * 1.5
123
+
124
+ # Rewind again and start reading all commands from scratch.
125
+ @context.socket.rewind
126
+ assert_equal password_command.command, @context.socket.readline.chomp
127
+ assert_equal nick_command.command, @context.socket.readline.chomp
128
+
129
+ # There should be no more commands available.
130
+ assert_raise(EOFError) { @context.socket.readline }
131
+
132
+ # Stop the command handler.
133
+ @command_handler.stop
134
+
135
+ end
136
+
137
+ end
@@ -0,0 +1,72 @@
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: join_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/join_command'
27
+ require 'irc/models/network'
28
+ require 'test/unit'
29
+
30
+ class IRC::Commands::JoinCommandTest < Test::Unit::TestCase
31
+
32
+ def test_command_with_name
33
+ assert_equal "JOIN #ircguerilla", IRC::Commands::JoinCommand.new("#ircguerilla").command
34
+ end
35
+
36
+ def test_command_with_names
37
+ assert_equal "JOIN #ircguerilla,#mp3", IRC::Commands::JoinCommand.new(["#ircguerilla", "#mp3"]).command
38
+ end
39
+
40
+ def test_command_with_channel
41
+ channel = IRC::Models::Network.new(:name => "Efnet").create_channel("#ircguerilla")
42
+ assert_equal "JOIN #ircguerilla", IRC::Commands::JoinCommand.new(channel).command
43
+ end
44
+
45
+ def test_command_with_channels
46
+ channels = Array.new
47
+ channels << IRC::Models::Network.new(:name => "Efnet").create_channel("#ircguerilla")
48
+ channels << IRC::Models::Network.new(:name => "Efnet").create_channel("#mp3")
49
+ assert_equal "JOIN #ircguerilla,#mp3", IRC::Commands::JoinCommand.new(channels).command
50
+ end
51
+
52
+ def test_command_with_name_and_password
53
+ assert_equal "JOIN #ircguerilla secret", IRC::Commands::JoinCommand.new("#ircguerilla", "secret").command
54
+ end
55
+
56
+ def test_command_with_names_and_passwords
57
+ assert_equal "JOIN #ircguerilla,#mp3 secret1,secret2", IRC::Commands::JoinCommand.new(["#ircguerilla", "#mp3"], ["secret1", "secret2"]).command
58
+ end
59
+
60
+ def test_command_with_channel_and_password
61
+ channel = IRC::Models::Network.new(:name => "Efnet").create_channel("#ircguerilla")
62
+ assert_equal "JOIN #ircguerilla secret", IRC::Commands::JoinCommand.new(channel, "secret").command
63
+ end
64
+
65
+ def test_command_with_channels_and_passwords
66
+ channels = Array.new
67
+ channels << IRC::Models::Network.new(:name => "Efnet").create_channel("#ircguerilla")
68
+ channels << IRC::Models::Network.new(:name => "Efnet").create_channel("#mp3")
69
+ assert_equal "JOIN #ircguerilla,#mp3 secret1,secret2", IRC::Commands::JoinCommand.new(channels, ["secret1", "secret2"]).command
70
+ end
71
+
72
+ 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: nick_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/nick_command'
27
+ require 'test/unit'
28
+
29
+ class IRC::Commands::NickCommandTest < Test::Unit::TestCase
30
+
31
+ def test_command
32
+ assert_equal "NICK fumanshu 12", IRC::Commands::NickCommand.new("fumanshu", 12).command
33
+ end
34
+
35
+ end
@@ -0,0 +1,52 @@
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: part_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/part_command'
27
+ require 'irc/models/network'
28
+ require 'test/unit'
29
+
30
+ class IRC::Commands::PartCommandTest < Test::Unit::TestCase
31
+
32
+ def test_command_with_name
33
+ assert_equal "PART #ircguerilla", IRC::Commands::PartCommand.new("#ircguerilla").command
34
+ end
35
+
36
+ def test_command_with_names
37
+ assert_equal "PART #ircguerilla,#mp3", IRC::Commands::PartCommand.new(["#ircguerilla", "#mp3"]).command
38
+ end
39
+
40
+ def test_command_with_channel
41
+ channel = IRC::Models::Network.new(:name => "Efnet").create_channel("#ircguerilla")
42
+ assert_equal "PART #ircguerilla", IRC::Commands::PartCommand.new(channel).command
43
+ end
44
+
45
+ def test_command_with_channels
46
+ channels = Array.new
47
+ channels << IRC::Models::Network.new(:name => "Efnet").create_channel("#ircguerilla")
48
+ channels << IRC::Models::Network.new(:name => "Efnet").create_channel("#mp3")
49
+ assert_equal "PART #ircguerilla,#mp3", IRC::Commands::PartCommand.new(channels).command
50
+ end
51
+
52
+ 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: password_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/password_command'
27
+ require 'test/unit'
28
+
29
+ class IRC::Commands::PasswordCommandTest < Test::Unit::TestCase
30
+
31
+ def test_command
32
+ assert_equal "PASS secret", IRC::Commands::PasswordCommand.new("secret").command
33
+ end
34
+
35
+ end
@@ -0,0 +1,36 @@
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_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/ping_command'
27
+ require 'test/unit'
28
+
29
+ class IRC::Commands::PingCommandTest < Test::Unit::TestCase
30
+
31
+ def test_command
32
+ assert_equal "PING WiZ", IRC::Commands::PingCommand.new("WiZ").command
33
+ assert_equal "PING WiZ irc.efnet.pl", IRC::Commands::PingCommand.new("WiZ", "irc.efnet.pl").command
34
+ end
35
+
36
+ end
@@ -0,0 +1,36 @@
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: pong_command_test.rb 85 2006-08-13 11:42:07Z roman $
25
+ #
26
+ require 'irc/commands/pong_command'
27
+ require 'test/unit'
28
+
29
+ class IRC::Commands::PongCommandTest < Test::Unit::TestCase
30
+
31
+ def test_command
32
+ assert_equal "PONG csd.bu.edu", IRC::Commands::PongCommand.new("csd.bu.edu").command
33
+ assert_equal "PONG csd.bu.edu tolsun.oulu.fi", IRC::Commands::PongCommand.new("csd.bu.edu", "tolsun.oulu.fi").command
34
+ end
35
+
36
+ end