irc_parser 0.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 (68) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +105 -0
  3. data/Rakefile +155 -0
  4. data/extra/benchmark.rb +41 -0
  5. data/irc_parser.gemspec +98 -0
  6. data/lib/irc_parser.rb +25 -0
  7. data/lib/irc_parser/factory.erb +53 -0
  8. data/lib/irc_parser/helper.rb +71 -0
  9. data/lib/irc_parser/messages.rb +96 -0
  10. data/lib/irc_parser/messages/commands.rb +274 -0
  11. data/lib/irc_parser/messages/errors.rb +51 -0
  12. data/lib/irc_parser/messages/replies.rb +212 -0
  13. data/lib/irc_parser/parser.rb +557 -0
  14. data/lib/irc_parser/parser.rl +89 -0
  15. data/spec/fixtures/from_weechat.rb +24 -0
  16. data/spec/fixtures/inbound.log +3959 -0
  17. data/spec/irc_parser/helper_spec.rb +32 -0
  18. data/spec/irc_parser/irc_parser_spec.rb +12 -0
  19. data/spec/irc_parser/messages_spec.rb +195 -0
  20. data/spec/irc_parser/parser_spec.rb +9 -0
  21. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_1_password_message_spec.rb +28 -0
  22. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_2_nick_message_spec.rb +35 -0
  23. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_3_user_message_spec.rb +47 -0
  24. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_4_server_message_spec.rb +33 -0
  25. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_5_oper_spec.rb +17 -0
  26. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_6_quit_spec.rb +17 -0
  27. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_7_server_quit_message_spec.rb +32 -0
  28. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_1_join_message_spec.rb +65 -0
  29. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_2_part_message_spec.rb +23 -0
  30. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_3_1_channel_modes_spec.rb +159 -0
  31. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_3_2_user_modes_spec.rb +55 -0
  32. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_4_topic_message_spec.rb +36 -0
  33. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_5_names_message_spec.rb +25 -0
  34. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_6_list_message_spec.rb +23 -0
  35. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_7_invite_message_spec.rb +31 -0
  36. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_8_kick_command_spec.rb +56 -0
  37. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_1_version_message_spec.rb +30 -0
  38. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_2_stats_message_spec.rb +32 -0
  39. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_3_links_message_spec.rb +31 -0
  40. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_4_time_message_spec.rb +34 -0
  41. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_5_connect_message_spec.rb +32 -0
  42. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_6_trace_message_spec.rb +28 -0
  43. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_7_admin_command_spec.rb +28 -0
  44. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_8_info_command_spec.rb +38 -0
  45. data/spec/irc_parser/rfc1459/4_4_sending_messages/4_4_1_private_messages_spec.rb +63 -0
  46. data/spec/irc_parser/rfc1459/4_4_sending_messages/4_4_2_notice_spec.rb +63 -0
  47. data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_1_who_query_spec.rb +27 -0
  48. data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_2_whois_query_spec.rb +27 -0
  49. data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_3_whowas_spec.rb +40 -0
  50. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_1_kill_message_spec.rb +20 -0
  51. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_2_ping_message_spec.rb +35 -0
  52. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_3_pong_message_spec.rb +26 -0
  53. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_4_error_spec.rb +26 -0
  54. data/spec/irc_parser/rfc1459/5_0_optionals/5_1_0_away_spec.rb +25 -0
  55. data/spec/irc_parser/rfc1459/5_0_optionals/5_2_0_rehash_message_spec.rb +14 -0
  56. data/spec/irc_parser/rfc1459/5_0_optionals/5_3_0_restart_message_spec.rb +14 -0
  57. data/spec/irc_parser/rfc1459/5_0_optionals/5_4_0_summon_message_spec.rb +28 -0
  58. data/spec/irc_parser/rfc1459/5_0_optionals/5_5_0_users_spec.rb +27 -0
  59. data/spec/irc_parser/rfc1459/5_0_optionals/5_6_0_operwall_message_spec.rb +17 -0
  60. data/spec/irc_parser/rfc1459/5_0_optionals/5_7_0_userhost_message_spec.rb +16 -0
  61. data/spec/irc_parser/rfc1459/5_0_optionals/5_8_0_ison_message_spec.rb +16 -0
  62. data/spec/irc_parser/rfc1459/6_0_replies/6_1_error_parsing_spec.rb +488 -0
  63. data/spec/irc_parser/rfc1459/6_0_replies/6_2_command_responses_generation_spec.rb +934 -0
  64. data/spec/irc_parser/rfc2812/5_1_command_responses/5_1_command_responses_spec.rb +63 -0
  65. data/spec/spec_helper.rb +12 -0
  66. data/spec/support/messages_helper.rb +24 -0
  67. data/spec/support/simplecov.rb +12 -0
  68. metadata +185 -0
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser::Helper, "in general" do
4
+
5
+ def with_channel_helpers(str)
6
+ str.tap { |str| str.extend(IRCParser::Helper::Channel) }
7
+ end
8
+
9
+ def with_nick_helpers(str)
10
+ str.tap { |str| str.extend(IRCParser::Helper::NicknameHelpers) }
11
+ end
12
+
13
+ it "knows valid and invalid nick names" do
14
+ with_nick_helpers("emmanuel").should be_valid_nick
15
+ with_nick_helpers("1emmanuel").should_not be_valid_nick
16
+ end
17
+
18
+ it "knows valid and invalid channel names, and channel modes" do
19
+ IRCParser::Helper::CHANNEL_PREFIXES.values.each do |prefix|
20
+ with_channel_helpers("#{prefix}hola").should be_valid_channel_name
21
+ with_channel_helpers("#{prefix}hola").should_not be_invalid_channel_name
22
+ end
23
+
24
+ with_channel_helpers("hola").should be_invalid_channel_name
25
+ with_channel_helpers("hola").should_not be_valid_channel_name
26
+
27
+ with_channel_helpers("+hola").should be_modeless_channel
28
+ with_channel_helpers("#hola").should be_normal_channel
29
+ with_channel_helpers("!hola").should be_safe_channel
30
+ with_channel_helpers("&hola").should be_local_channel
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser do
4
+ it "provides a helper method to generate messages" do
5
+ IRCParser.message("MODE", nil, ["nick"]).to_s.should == "MODE nick\r\n"
6
+ IRCParser.message("MODE") { |msg| msg.target = "nick" }.to_s.should == "MODE nick\r\n"
7
+ end
8
+
9
+ it "provides a helper method to generate messages" do
10
+ IRCParser.message("PASS") { |msg| msg.password = "pass" }.to_s.should == "PASS pass\r\n"
11
+ end
12
+ end
@@ -0,0 +1,195 @@
1
+ require 'spec_helper'
2
+ describe IRCParser::Messages do
3
+ context "Factories" do
4
+
5
+ context "in general" do
6
+ context "commands" do
7
+ SomeCommand = IRCParser::Messages.message_class(:SomeCommand)
8
+ subject { SomeCommand }
9
+
10
+ its(:name) { should == :SomeCommand }
11
+ its(:to_sym) { should == :some_command }
12
+ its(:identifier) { should == :SOMECOMMAND }
13
+ its(:postfix_format) { should == nil }
14
+ its(:is_error?) { should be_false }
15
+ its(:is_reply?) { should be_false }
16
+ its(:is_command?) { should be_true }
17
+ end
18
+
19
+ context "errors" do
20
+ ErrSomeError = IRCParser::Messages.message_class(:ErrSomeError, "1400")
21
+ subject { ErrSomeError }
22
+
23
+ its(:name) { should == :ErrSomeError }
24
+ its(:to_sym) { should == :err_some_error }
25
+ its(:identifier) { should == :"1400" }
26
+ its(:postfix_format) { should == nil }
27
+ its(:is_error?) { should be_true }
28
+ its(:is_reply?) { should be_false }
29
+ its(:is_command?) { should be_false }
30
+ end
31
+
32
+ context "replies" do
33
+ RplSomeReply = IRCParser::Messages.message_class(:RplSomeReply, "1300")
34
+ subject { RplSomeReply }
35
+
36
+ its(:name) { should == :RplSomeReply }
37
+ its(:to_sym) { should == :rpl_some_reply }
38
+ its(:identifier) { should == :"1300" }
39
+ its(:postfix_format) { should == nil }
40
+ its(:is_error?) { should be_false }
41
+ its(:is_reply?) { should be_true }
42
+ its(:is_command?) { should be_false }
43
+ end
44
+ end
45
+
46
+ context "parameter-less messages" do
47
+ ParamLess = IRCParser::Messages.message_class :ParamLess
48
+
49
+ let(:message) { ParamLess.new }
50
+
51
+ it "generates a parameter-less message" do
52
+ message.to_s.should == "PARAMLESS\r\n"
53
+ end
54
+
55
+ it "generates a parameter-less message with prefix" do
56
+ message.prefix = "someone"
57
+ message.to_s.should == ":someone PARAMLESS\r\n"
58
+ end
59
+
60
+ it "generates a parameter-less message with postfix" do
61
+ message.postfix = "something cool"
62
+ message.to_s.should == "PARAMLESS :something cool\r\n"
63
+ end
64
+
65
+ it "generates a parameter-less message with prefix and postfix" do
66
+ message.prefix = "someone"
67
+ message.postfix = "something cool"
68
+ message.to_s.should == ":someone PARAMLESS :something cool\r\n"
69
+ end
70
+ end
71
+
72
+ context "one parameter" do
73
+ OneParam = IRCParser::Messages.message_class :OneParam, :nick
74
+
75
+ let(:message) { OneParam.new "", ["Tony"] }
76
+
77
+ it "generates a message with one parameter" do
78
+ message.to_s.should == "ONEPARAM Tony\r\n"
79
+ end
80
+
81
+ it "generates a message with prefix" do
82
+ message.prefix = "someone"
83
+ message.to_s.should == ":someone ONEPARAM Tony\r\n"
84
+ end
85
+
86
+ it "generates a message with postfix" do
87
+ message.postfix = "something cool"
88
+ message.to_s.should == "ONEPARAM Tony :something cool\r\n"
89
+ end
90
+
91
+ it "generates a message with prefix and postfix" do
92
+ message.prefix = "someone"
93
+ message.postfix = "something cool"
94
+ message.to_s.should == ":someone ONEPARAM Tony :something cool\r\n"
95
+ end
96
+ end
97
+
98
+ context "two parameters" do
99
+ TwoParams = IRCParser::Messages.message_class :TwoParams, {:nick => {:default => "*"}}, :name
100
+
101
+ let(:message) { TwoParams.new "", ["Tony", "Motola"] }
102
+
103
+ it "defaults to * for missing fields with defaults" do
104
+ TwoParams.new.to_s.should == "TWOPARAMS *\r\n"
105
+ TwoParams.new("", ["Moncho", nil]).to_s.should == "TWOPARAMS Moncho\r\n"
106
+ TwoParams.new("", ["", "Moncho"]).to_s.should == "TWOPARAMS * Moncho\r\n"
107
+ end
108
+
109
+ it "generates a message with one parameter" do
110
+ message.to_s.should == "TWOPARAMS Tony Motola\r\n"
111
+ end
112
+
113
+ it "generates a message with prefix" do
114
+ message.prefix = "someone"
115
+ message.to_s.should == ":someone TWOPARAMS Tony Motola\r\n"
116
+ end
117
+
118
+ it "generates a with postfix" do
119
+ message.postfix = "something cool"
120
+ message.to_s.should == "TWOPARAMS Tony Motola :something cool\r\n"
121
+ end
122
+
123
+ it "generates a message with prefix and postfix" do
124
+ message.prefix = "someone"
125
+ message.postfix = "something cool"
126
+ message.to_s.should == ":someone TWOPARAMS Tony Motola :something cool\r\n"
127
+ end
128
+ end
129
+
130
+ context "parameters with configuration" do
131
+ WithConfig = IRCParser::Messages.message_class :WithConfig, {:nick => {:default => "Titus"}}, {:names => {:csv => " "}}
132
+
133
+ let(:message) { WithConfig.new "", ["", ["Tito", "Puente"]] }
134
+
135
+ it "generates a message with the defaults fill up" do
136
+ message.to_s.should == "WITHCONFIG Titus Tito Puente\r\n"
137
+ end
138
+
139
+ it "generates a message with prefix" do
140
+ message.prefix = "someone"
141
+ message.to_s.should == ":someone WITHCONFIG Titus Tito Puente\r\n"
142
+ end
143
+
144
+ it "generates a message with postfix" do
145
+ message.postfix = "something cool"
146
+ message.to_s.should == "WITHCONFIG Titus Tito Puente :something cool\r\n"
147
+ end
148
+
149
+ it "generates a message with prefix and postfix" do
150
+ message.prefix = "someone"
151
+ message.postfix = "something cool"
152
+ message.to_s.should == ":someone WITHCONFIG Titus Tito Puente :something cool\r\n"
153
+ end
154
+ end
155
+
156
+ context "defining classes" do
157
+ IRCParser::Messages.define_message(:MyCommand)
158
+ IRCParser::Messages.define_message(:ErrMyErr, "1200")
159
+ IRCParser::Messages.define_message(:RplMyRpl, "1600")
160
+
161
+ it "defines classes in the Messages namespace" do
162
+ defined?(IRCParser::Messages::MyCommand).should be_true
163
+ defined?(IRCParser::Messages::ErrMyErr).should be_true
164
+ defined?(IRCParser::Messages::RplMyRpl).should be_true
165
+ end
166
+
167
+ it "is able to retrieve the classes with different keys" do
168
+ IRCParser.message_class(:"MyCommand"). should == IRCParser::Messages::MyCommand
169
+ IRCParser.message_class(:"MYCOMMAND"). should == IRCParser::Messages::MyCommand
170
+ IRCParser.message_class(:my_command). should == IRCParser::Messages::MyCommand
171
+ IRCParser.message_class("my_command"). should == IRCParser::Messages::MyCommand
172
+ IRCParser.message_class("MYCOMMAND"). should == IRCParser::Messages::MyCommand
173
+
174
+ IRCParser.message_class(:"ERRMYERR"). should == IRCParser::Messages::ErrMyErr
175
+ IRCParser.message_class(:"ErrMyErr"). should == IRCParser::Messages::ErrMyErr
176
+ IRCParser.message_class(:err_my_err). should == IRCParser::Messages::ErrMyErr
177
+ IRCParser.message_class("ERRMYERR"). should == IRCParser::Messages::ErrMyErr
178
+ IRCParser.message_class("ErrMyErr"). should == IRCParser::Messages::ErrMyErr
179
+ IRCParser.message_class("err_my_err"). should == IRCParser::Messages::ErrMyErr
180
+ IRCParser.message_class("1200"). should == IRCParser::Messages::ErrMyErr
181
+ IRCParser.message_class(1200). should == IRCParser::Messages::ErrMyErr
182
+
183
+ IRCParser.message_class(:"RPLMYRPL"). should == IRCParser::Messages::RplMyRpl
184
+ IRCParser.message_class(:"RplMyRpl"). should == IRCParser::Messages::RplMyRpl
185
+ IRCParser.message_class(:rpl_my_rpl). should == IRCParser::Messages::RplMyRpl
186
+ IRCParser.message_class("RPLMYRPL"). should == IRCParser::Messages::RplMyRpl
187
+ IRCParser.message_class("RplMyRpl"). should == IRCParser::Messages::RplMyRpl
188
+ IRCParser.message_class("rpl_my_rpl"). should == IRCParser::Messages::RplMyRpl
189
+ IRCParser.message_class("1600"). should == IRCParser::Messages::RplMyRpl
190
+ IRCParser.message_class(1600). should == IRCParser::Messages::RplMyRpl
191
+ end
192
+ end
193
+
194
+ end
195
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parser" do
4
+ it "raises an exception on bad msg" do |message|
5
+ expect { IRCParser.parse("fail\r\n") }.to raise_error(IRCParser::ParserError)
6
+ expect { IRCParser.parse("LALALA nick\r\n") }.to raise_error(IRCParser::ParserError)
7
+ expect { IRCParser.parse("PASS nick\r\n") }.to_not raise_error(IRCParser::ParserError)
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing password msg" do
4
+
5
+ it_parses "PASS secretpasswordhere" do |msg|
6
+ msg.password.should == "secretpasswordhere"
7
+ end
8
+
9
+ it_parses "PASS" do |msg|
10
+ msg.password.should == nil
11
+ end
12
+
13
+ it_parses "PASS :" do |msg|
14
+ msg.password.should == ""
15
+ end
16
+
17
+ it_generates IRCParser::Messages::Pass, "PASS" do |msg|
18
+ msg.password = ""
19
+ end
20
+
21
+ it_generates IRCParser::Messages::Pass, "PASS" do |msg|
22
+ msg.password = nil
23
+ end
24
+
25
+ it_generates IRCParser::Messages::Pass, "PASS secretpasswordhere" do |msg|
26
+ msg.password = "secretpasswordhere"
27
+ end
28
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing nick msg" do
4
+
5
+ it_parses "NICK Wiz" do |msg| # Introducing new nick "Wiz".
6
+ msg.nick.should == "Wiz"
7
+ msg.hopcount.should be_nil
8
+ end
9
+
10
+ it_parses "NICK Wiz 10" do |msg| # nick "Wiz" with hopcount.
11
+ msg.nick.should == "Wiz"
12
+ msg.hopcount.should == "10"
13
+ end
14
+
15
+ it_parses ":WiZ NICK Kilroy" do |msg| # WiZ changed his nickname to Kilroy.
16
+ msg.nick.should == "Kilroy"
17
+ msg.prefix.should == "WiZ"
18
+ end
19
+
20
+ #------------------------------------------------------------------------------
21
+
22
+ it_generates IRCParser::Messages::Nick, "NICK Wiz" do |msg| # Introducing new nick "Wiz".
23
+ msg.nick = "Wiz"
24
+ end
25
+
26
+ it_generates IRCParser::Messages::Nick, "NICK Wiz 10" do |msg| # nick "Wiz" with hopcount.
27
+ msg.nick = "Wiz"
28
+ msg.hopcount = "10"
29
+ end
30
+
31
+ it_generates IRCParser::Messages::Nick, ":WiZ NICK Kilroy" do |msg| # WiZ changed his nickname to Kilroy.
32
+ msg.nick = "Kilroy"
33
+ msg.prefix = "WiZ"
34
+ end
35
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing user msg" do
4
+
5
+ it_parses "USER guest tolmoon tolsun :Ronnie Reagan" do |msg|
6
+ msg.mode.should == "tolmoon"
7
+ msg.realname.should == "Ronnie Reagan"
8
+ msg.servername.should == "tolsun"
9
+ msg.user.should == "guest"
10
+ end
11
+
12
+ it_parses ":testnick USER guest tolmoon tolsun :Ronnie Reagan" do |msg|
13
+ msg.mode.should == "tolmoon"
14
+ msg.prefix.should == "testnick"
15
+ msg.realname.should == "Ronnie Reagan"
16
+ msg.servername.should == "tolsun"
17
+ msg.user.should == "guest"
18
+ end
19
+
20
+ #------------------------------------------------------------------------------
21
+
22
+ it_generates IRCParser::Messages::User, "USER guest tolmoon tolsun :Ronnie Reagan" do |msg|
23
+ msg.mode= "tolmoon"
24
+ msg.realname= "Ronnie Reagan"
25
+ msg.servername= "tolsun"
26
+ msg.user= "guest"
27
+ end
28
+
29
+ it_generates IRCParser::Messages::User, ":testnick USER guest tolmoon tolsun :Ronnie Reagan" do |msg|
30
+ msg.servername= "tolsun"
31
+ msg.mode= "tolmoon"
32
+ msg.prefix= "testnick"
33
+ msg.realname= "Ronnie Reagan"
34
+ msg.user= "guest"
35
+ end
36
+
37
+ it_generates IRCParser::Messages::User, "USER guest * * :Ronnie Reagan" do |msg|
38
+ msg.realname= "Ronnie Reagan"
39
+ msg.user= "guest"
40
+ end
41
+
42
+ it_generates IRCParser::Messages::User, ":testnick USER guest * * :Ronnie Reagan" do |msg|
43
+ msg.prefix= "testnick"
44
+ msg.user= "guest"
45
+ msg.realname= "Ronnie Reagan"
46
+ end
47
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing server msg" do
4
+
5
+ it_parses "SERVER test.oulu.fi 1 :[tolsun.oulu.fi] Experimental server" do |msg|
6
+ msg.server.should == "test.oulu.fi"
7
+ msg.hopcount.should == 1
8
+ msg.info.should == "[tolsun.oulu.fi] Experimental server"
9
+ end
10
+
11
+ it_parses ":tolsun.oulu.fi SERVER csd.bu.edu 5 :BU Central Server" do |msg|
12
+ msg.prefix.should == "tolsun.oulu.fi"
13
+ msg.server.should == "csd.bu.edu"
14
+ msg.hopcount.should == 5
15
+ msg.info.should == "BU Central Server"
16
+ end
17
+
18
+ #------------------------------------------------------------------------------
19
+
20
+ it_generates IRCParser::Messages::Server, "SERVER test.oulu.fi 1 :[tolsun.oulu.fi] Experimental server" do |msg|
21
+ msg.server= "test.oulu.fi"
22
+ msg.hopcount= 1
23
+ msg.info= "[tolsun.oulu.fi] Experimental server"
24
+ end
25
+
26
+ it_generates IRCParser::Messages::Server, ":tolsun.oulu.fi SERVER csd.bu.edu 5 :BU Central Server" do |msg|
27
+ msg.prefix= "tolsun.oulu.fi"
28
+ msg.server= "csd.bu.edu"
29
+ msg.hopcount= 5
30
+ msg.info= "BU Central Server"
31
+ end
32
+
33
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing oper" do
4
+
5
+ it_parses "OPER foo bar" do |msg|
6
+ msg.user.should == "foo"
7
+ msg.password.should == "bar"
8
+ end
9
+
10
+ #------------------------------------------------------------------------------
11
+
12
+ it_generates IRCParser::Messages::Oper, "OPER foo bar" do |msg|
13
+ msg.user= "foo"
14
+ msg.password= "bar"
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing quit" do
4
+
5
+ it_parses ":some_nick!some_user@some_server QUIT :Gone to have lunch" do |msg|
6
+ msg.prefix.should == "some_nick!some_user@some_server"
7
+ msg.quit_message.should == "Gone to have lunch"
8
+ end
9
+
10
+ #------------------------------------------------------------------------------
11
+
12
+ it_generates IRCParser::Messages::Quit, ":some_nick!some_user@some_server QUIT :Gone to have lunch" do |msg|
13
+ msg.prefix = "some_nick!some_user@some_server"
14
+ msg.quit_message= "Gone to have lunch"
15
+ end
16
+
17
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing server quit msg" do
4
+
5
+ it_parses "SQUIT tolsun.oulu.fi :Bad Link ?" do |msg|
6
+ msg.server.should == "tolsun.oulu.fi"
7
+ msg.reason.should == "Bad Link ?"
8
+ end
9
+
10
+ it_parses ":Trillian SQUIT cm22.eng.umd.edu :Server out of control" do |msg|
11
+ msg.server.should == "cm22.eng.umd.edu"
12
+ msg.reason.should == "Server out of control"
13
+ msg.prefix.should == "Trillian"
14
+ msg.server.should == "cm22.eng.umd.edu"
15
+ msg.reason.should == "Server out of control"
16
+ end
17
+
18
+ #------------------------------------------------------------------------------
19
+
20
+ it_generates IRCParser::Messages::SQuit, "SQUIT tolsun.oulu.fi :Bad Link ?" do |msg|
21
+ msg.server= "tolsun.oulu.fi"
22
+ msg.reason= "Bad Link ?"
23
+ end
24
+
25
+ it_generates IRCParser::Messages::SQuit, ":Trillian SQUIT cm22.eng.umd.edu :Server out of control" do |msg|
26
+ msg.server= "cm22.eng.umd.edu"
27
+ msg.reason= "Server out of control"
28
+ msg.prefix= "Trillian"
29
+ msg.server= "cm22.eng.umd.edu"
30
+ msg.reason= "Server out of control"
31
+ end
32
+ end