ruby-net-nntp 0.2.2 → 1.0.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.
- data/CHANGELOG +145 -128
- data/CHANGELOG.debian +5 -0
- data/Manifest.txt +37 -0
- data/README.txt +69 -0
- data/Rakefile +28 -0
- data/build-stamp +0 -0
- data/lib/net/nntp.rb +261 -327
- data/lib/net/nntp/request.rb +840 -0
- data/lib/net/nntp/response.rb +731 -0
- data/lib/net/nntp/version.rb +2 -1
- data/script/console +12 -0
- data/spec/net/nntp/request_spec.rb +771 -0
- data/spec/net/nntp/response_spec.rb +994 -0
- data/spec/net/nntp_spec.rb +634 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/stories/all.rb +2 -0
- data/spec/stories/helper.rb +17 -0
- data/spec/stories/net/nntp.rb +7 -0
- data/spec/stories/net/nntp.story +12 -0
- data/spec/stories/steps/nntp.rb +18 -0
- data/tasks/ann.rake +81 -0
- data/tasks/bones.rake +21 -0
- data/tasks/gem.rake +126 -0
- data/tasks/git.rake +41 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/mercurial.rake +6 -0
- data/tasks/notes.rake +28 -0
- data/tasks/pallet.rake +17 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +268 -0
- data/tasks/spec.rake +55 -0
- data/tasks/svn.rake +48 -0
- data/tasks/test.rake +38 -0
- metadata +57 -33
- data/README +0 -46
- data/lib/net/nntp/article.rb +0 -188
- data/lib/net/nntp/group.rb +0 -83
- data/test/functional/test_nntp.rb +0 -288
- data/test/mock/mock_socket.rb +0 -359
- data/test/unit/test_nntp_article.rb +0 -98
- data/test/unit/test_nntp_group.rb +0 -60
@@ -0,0 +1,994 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
+
|
3
|
+
describe Net::NNTP::FormatHeader do
|
4
|
+
it 'should parse a simple header ending with a colon' do
|
5
|
+
@header = Net::NNTP::FormatHeader.new('Date:')
|
6
|
+
@header.name.should == 'date'
|
7
|
+
@header.full.should == false
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should parse a header starting with a colon' do
|
11
|
+
@header = Net::NNTP::FormatHeader.new(':bytes')
|
12
|
+
@header.name.should == 'bytes'
|
13
|
+
@header.full.should == false
|
14
|
+
end
|
15
|
+
it 'should parse a header with the indicator "full" separated by a colon' do
|
16
|
+
@header = Net::NNTP::FormatHeader.new('Xref:full')
|
17
|
+
@header.name.should == 'xref'
|
18
|
+
@header.full.should == true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'Responses with body', :shared => true do
|
23
|
+
|
24
|
+
it 'should read the response from a string' do
|
25
|
+
@response.body = @body
|
26
|
+
@response.raw.should == @body
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should read the response from an IO object' do
|
30
|
+
raw = StringIO.new
|
31
|
+
raw << @body
|
32
|
+
raw.rewind
|
33
|
+
@response.body = raw
|
34
|
+
@response.raw.should == @body
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should let the response be filled from a block' do
|
38
|
+
raw = StringIO.new
|
39
|
+
raw << @body
|
40
|
+
raw.rewind
|
41
|
+
@response.instance_variable_set(:@body, nil)
|
42
|
+
@response.body { raw.string }
|
43
|
+
@response.raw.should == @body
|
44
|
+
@response.instance_variable_set(:@body, nil)
|
45
|
+
@response.body { raw }
|
46
|
+
@response.raw.should == @body
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'Single Line Responses', :shared => true do
|
52
|
+
it 'must not be a multiline response' do
|
53
|
+
@response.should_not be_multiline
|
54
|
+
@response.body.should be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe Net::NNTP::InformationResponse do
|
59
|
+
end
|
60
|
+
|
61
|
+
describe Net::NNTP::HelpResponse do
|
62
|
+
before do
|
63
|
+
@response = Net::NNTP::HelpResponse.new(@request, '100', 'Help text follows')
|
64
|
+
@body = <<-EOF
|
65
|
+
100 Help text follows
|
66
|
+
this is a help text
|
67
|
+
not much to look at.
|
68
|
+
.
|
69
|
+
EOF
|
70
|
+
end
|
71
|
+
it 'must not be a generic response' do
|
72
|
+
@response.should_not be_generic
|
73
|
+
end
|
74
|
+
it_should_behave_like 'Responses with body'
|
75
|
+
end
|
76
|
+
|
77
|
+
describe Net::NNTP::CapabilityList do
|
78
|
+
before do
|
79
|
+
@response = Net::NNTP::CapabilityList.new(@request, '101', 'Capability list:')
|
80
|
+
@body = "VERSION 2\r\nREADER\r\nLIST ACTIVE NEWSGROUPS\r\n.\r\n"
|
81
|
+
end
|
82
|
+
it 'must not be a generic response' do
|
83
|
+
@response.should_not be_generic
|
84
|
+
end
|
85
|
+
it 'should have capabilities' do
|
86
|
+
@response.should respond_to(:capabilities)
|
87
|
+
end
|
88
|
+
it 'should parse capabilities from body and make them accessible' do
|
89
|
+
@response.body = @body
|
90
|
+
@response.capabilities['version'].should == '2'
|
91
|
+
@response.capabilities['reader'].should be_true
|
92
|
+
@response.capabilities['list'].should == ['ACTIVE', 'NEWSGROUPS']
|
93
|
+
@response.capabilities.should_not have_key('post')
|
94
|
+
@response.capabilities['post'].should be_nil
|
95
|
+
end
|
96
|
+
it_should_behave_like 'Responses with body'
|
97
|
+
end
|
98
|
+
|
99
|
+
describe Net::NNTP::DateResponse do
|
100
|
+
before do
|
101
|
+
@response = Net::NNTP::Response.create(@request, '111 20080815124533')
|
102
|
+
end
|
103
|
+
it_should_behave_like "Single Line Responses"
|
104
|
+
|
105
|
+
it 'should return a valid date' do
|
106
|
+
@response.date.should == DateTime.parse('August 15 2008 12:45:33')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe Net::NNTP::OKResponse do
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'Multiline Responses', :shared => true do
|
114
|
+
it 'must be a multiline response' do
|
115
|
+
@response.should be_multiline
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe Net::NNTP::PostingAllowed do
|
120
|
+
before do
|
121
|
+
@response = Net::NNTP::PostingAllowed.new(@request, '200', 'Posting allowed')
|
122
|
+
end
|
123
|
+
it_should_behave_like 'Single Line Responses'
|
124
|
+
end
|
125
|
+
|
126
|
+
describe Net::NNTP::PostingProhibited do
|
127
|
+
before do
|
128
|
+
@response = Net::NNTP::PostingProhibited.new(@request, '201', 'Posting prohibited')
|
129
|
+
end
|
130
|
+
it_should_behave_like 'Single Line Responses'
|
131
|
+
end
|
132
|
+
|
133
|
+
describe Net::NNTP::ConnectionClosing do
|
134
|
+
before do
|
135
|
+
@response = Net::NNTP::ConnectionClosing.new(@request, '205', 'Connection closing')
|
136
|
+
end
|
137
|
+
it_should_behave_like 'Single Line Responses'
|
138
|
+
it 'should request closing of the socket' do
|
139
|
+
@response.force_close?.should be_true
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe Net::NNTP::GroupSelected do
|
144
|
+
before do
|
145
|
+
@request = Net::NNTP::Group.new('misc.test')
|
146
|
+
@response = Net::NNTP::GroupSelected.new(@request, '211', '1234 3000234 3002322 misc.test list follows')
|
147
|
+
@body ="300234\r\n300237\r\n300238\r\n300239\r\n3002322\r\n.\r\n"
|
148
|
+
end
|
149
|
+
it_should_behave_like 'Responses with body'
|
150
|
+
it 'should have a group name' do
|
151
|
+
@response.group.name.should == 'misc.test'
|
152
|
+
end
|
153
|
+
it 'should have the article numbers' do
|
154
|
+
@response.group.number.should == 1234
|
155
|
+
end
|
156
|
+
it 'should have the low watermark' do
|
157
|
+
@response.group.low.should == 3000234
|
158
|
+
end
|
159
|
+
it 'should have the high watermark' do
|
160
|
+
@response.group.high.should == 3002322
|
161
|
+
end
|
162
|
+
it 'should have an optional body and parse numbers' do
|
163
|
+
@request = Net::NNTP::Group.new('misc.test')
|
164
|
+
@response = Net::NNTP::GroupSelected.new(@request, '211', '1234 3000234 3002322 misc.test list follows')
|
165
|
+
@response.should_not have_body
|
166
|
+
@request = Net::NNTP::Listgroup.new('misc.test')
|
167
|
+
@response = Net::NNTP::GroupSelected.new(@request, '211', '1234 3000234 3002322 misc.test list follows')
|
168
|
+
@response.body = "300234\r\n300237\r\n300238\r\n300239\r\n3002322\r\n.\r\n"
|
169
|
+
@response.should have_body
|
170
|
+
@response.list.should == ["300234", "300237", "300238", "300239", "3002322"]
|
171
|
+
end
|
172
|
+
it 'should be a multiline response if the request is a Listgroup request' do
|
173
|
+
@request = Net::NNTP::Listgroup.new('misc.test')
|
174
|
+
@response = Net::NNTP::GroupSelected.new(@request, '211', '1234 3000234 3002322 misc.test list follows')
|
175
|
+
@body ="300234\r\n300237\r\n300238\r\n300239\r\n3002322\r\n.\r\n"
|
176
|
+
@response.should be_multiline
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should not be a multiline response if the request is a Group request' do
|
180
|
+
@request = Net::NNTP::Group.new('misc.test')
|
181
|
+
@response = Net::NNTP::GroupSelected.new(@request, '211', '1234 3000234 3002322 misc.test list follows')
|
182
|
+
@response.should_not be_multiline
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
describe Net::NNTP::ListInformationFollows do
|
188
|
+
before do
|
189
|
+
@request = Net::NNTP::List.new
|
190
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
191
|
+
@body = "at.test 3 5 y\r\nalt.test 8 30 y\r\n"
|
192
|
+
@response.body = @body
|
193
|
+
end
|
194
|
+
it_should_behave_like 'Multiline Responses'
|
195
|
+
it_should_behave_like 'Responses with body'
|
196
|
+
|
197
|
+
it 'should parse the body to a list of groups on LIST (ACTIVE)' do
|
198
|
+
@request = Net::NNTP::List.new
|
199
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
200
|
+
@body = "at.test 3 5 y\r\nalt.test 8 30 y\n"
|
201
|
+
@response.body = @body
|
202
|
+
@response.list.should respond_to(:each)
|
203
|
+
@response.list[0].name.should == 'at.test'
|
204
|
+
@response.list[0].high.should == 5
|
205
|
+
@response.list[0].low.should == 3
|
206
|
+
@response.list[0].status.should == 'y'
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should parse the body to a list of groups on LIST ACTIVE.TIMES' do
|
210
|
+
@request = Net::NNTP::List.new('ACTIVE.TIMES')
|
211
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
212
|
+
@body = <<-EOF
|
213
|
+
misc.test 930445408 <creatme@isc.org>
|
214
|
+
alt.rfc-writers.recovery 930562309 <m@example.com>
|
215
|
+
tx.natives.recovery 930678923 <sob@academ.com>
|
216
|
+
.
|
217
|
+
EOF
|
218
|
+
@response.body = @body
|
219
|
+
@response.list.should respond_to(:each)
|
220
|
+
@response.list[0].name.should == 'misc.test'
|
221
|
+
@response.list[0].epoch.should == '930445408'
|
222
|
+
@response.list[0].creator.should == '<creatme@isc.org>'
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should parse the body to a list of distibution patterns on LIST DISTRIB.PATS' do
|
226
|
+
@request = Net::NNTP::List.new('DISTRIB.PATS')
|
227
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
228
|
+
@body = <<-EOF
|
229
|
+
10:local.*:local
|
230
|
+
5:*:world
|
231
|
+
20:local.here.*:thissite
|
232
|
+
.
|
233
|
+
EOF
|
234
|
+
@response.body = @body
|
235
|
+
@response.list.should respond_to(:each)
|
236
|
+
@response.list[0].priority.should == 10
|
237
|
+
@response.list[0].pattern.should == 'local.*'
|
238
|
+
@response.list[0].distribution.should == 'local'
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should parse the body to a list of fields on LIST HEADERS' do
|
242
|
+
@request = Net::NNTP::List.new('HEADERS')
|
243
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
244
|
+
@body = <<-EOF
|
245
|
+
Date
|
246
|
+
Distribution
|
247
|
+
From
|
248
|
+
Message-ID
|
249
|
+
References
|
250
|
+
Subject
|
251
|
+
Xref
|
252
|
+
:bytes
|
253
|
+
:lines
|
254
|
+
.
|
255
|
+
EOF
|
256
|
+
@response.body = @body
|
257
|
+
@response.list.should respond_to(:each)
|
258
|
+
@response.list[0].should == 'Date'
|
259
|
+
@response.list[1].should == 'Distribution'
|
260
|
+
@response.list[2].should == 'From'
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'should parse the body to a list of groups and their description on LIST NEWSGROUPS' do
|
264
|
+
@request = Net::NNTP::List.new('NEWSGROUPS')
|
265
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
266
|
+
@body = <<-EOF
|
267
|
+
misc.test General Usenet testing
|
268
|
+
alt.rfc-writers.recovery RFC Writers Recovery
|
269
|
+
tx.natives.recovery Texas Natives Recovery
|
270
|
+
.
|
271
|
+
EOF
|
272
|
+
@response.body = @body
|
273
|
+
@response.list.should respond_to(:each)
|
274
|
+
@response.list[0].name.should == 'misc.test'
|
275
|
+
@response.list[0].desc.should == 'General Usenet testing'
|
276
|
+
end
|
277
|
+
it 'should parse the body to a list of fields on LIST OVERVIEW.FMT' do
|
278
|
+
@request = Net::NNTP::List.new('OVERVIEW.FMT')
|
279
|
+
@response = Net::NNTP::ListInformationFollows.new(@request, '215', 'information follows')
|
280
|
+
@body = <<-EOF
|
281
|
+
Subject:
|
282
|
+
From:
|
283
|
+
Date:
|
284
|
+
Message-ID:
|
285
|
+
References:
|
286
|
+
:bytes
|
287
|
+
:lines
|
288
|
+
Xref:full
|
289
|
+
Distribution:full
|
290
|
+
.
|
291
|
+
EOF
|
292
|
+
@response.body = @body
|
293
|
+
@response.list.should respond_to(:each)
|
294
|
+
@response.list[0].name.should == 'subject'
|
295
|
+
@response.list[0].full.should be_false
|
296
|
+
@response.list[1].name.should == 'from'
|
297
|
+
@response.list[1].full.should be_false
|
298
|
+
@response.list[5].name.should == 'bytes'
|
299
|
+
@response.list[5].full.should be_false
|
300
|
+
@response.list[6].name.should == 'lines'
|
301
|
+
@response.list[6].full.should be_false
|
302
|
+
@response.list[8].name.should == 'distribution'
|
303
|
+
@response.list[8].full.should be_true
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe 'Article Responses', :shared => true do
|
308
|
+
it 'should return the article number' do
|
309
|
+
@response.number.should == 3000237
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'should return the message-id' do
|
313
|
+
@response.message_id.should == '<1234@example.org>'
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
describe Net::NNTP::ArticleResponse do
|
318
|
+
before do
|
319
|
+
@response = Net::NNTP::ArticleResponse.new(@request, '220', '3000237 <1234@example.org>')
|
320
|
+
@body =<<EOF
|
321
|
+
Path: ahost!demo!not-for-mail
|
322
|
+
From: "Demo User" <nobody@example.com>
|
323
|
+
Newsgroups: misc.test
|
324
|
+
Subject: I am just a test article
|
325
|
+
Date: 14 May 2008 11:40:23 +0200
|
326
|
+
Organization: An Example
|
327
|
+
Message-ID: <1234@example.com>
|
328
|
+
|
329
|
+
This is just a test article.
|
330
|
+
.But with special properties
|
331
|
+
...
|
332
|
+
..
|
333
|
+
EOF
|
334
|
+
@check_article = TMail::Mail.parse(@body.gsub(/^\./, "")).to_s
|
335
|
+
@preamble =<<-EOF
|
336
|
+
This is just a test article.
|
337
|
+
But with special properties
|
338
|
+
..
|
339
|
+
.
|
340
|
+
EOF
|
341
|
+
end
|
342
|
+
it_should_behave_like 'Multiline Responses'
|
343
|
+
it_should_behave_like 'Article Responses'
|
344
|
+
it_should_behave_like 'Responses with body'
|
345
|
+
|
346
|
+
|
347
|
+
it 'should return an article' do
|
348
|
+
@response.body = @body
|
349
|
+
@response.article.to_s.should == @check_article
|
350
|
+
@response.article.preamble.should == @preamble
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'should return an enumeration of headers' do
|
354
|
+
@response.body = @body
|
355
|
+
@response['Subject'].should == "I am just a test article"
|
356
|
+
end
|
357
|
+
|
358
|
+
end
|
359
|
+
|
360
|
+
describe Net::NNTP::HeaderResponse do
|
361
|
+
before do
|
362
|
+
@request = Net::NNTP::Head.new('3000237')
|
363
|
+
@response = Net::NNTP::HeaderResponse.new(@request, '221', '3000237 <1234@example.org>')
|
364
|
+
@body =<<EOF
|
365
|
+
Path: ahost!demo!not-for-mail
|
366
|
+
From: "Demo User" <nobody@example.com>
|
367
|
+
Newsgroups: misc.test
|
368
|
+
Subject: I am just a test article
|
369
|
+
Date: 14 May 2008 11:40:23 +0200
|
370
|
+
Organization: An Example
|
371
|
+
Message-ID: <1234@example.com>
|
372
|
+
.
|
373
|
+
EOF
|
374
|
+
end
|
375
|
+
it_should_behave_like 'Multiline Responses'
|
376
|
+
it_should_behave_like 'Article Responses'
|
377
|
+
it_should_behave_like 'Responses with body'
|
378
|
+
it 'should return an enumeration of headers' do
|
379
|
+
@response.body = @body
|
380
|
+
@response['Subject'].should == "I am just a test article"
|
381
|
+
@response.header['from'].to_s.should == 'Demo User <nobody@example.com>'
|
382
|
+
end
|
383
|
+
|
384
|
+
it 'should return an enumeration of numbers and contents if the request is a XHDR request' do
|
385
|
+
@request = Net::NNTP::Xhdr.new('Subject')
|
386
|
+
@response = Net::NNTP::HeaderResponse.new(@request, '221', 'Subject fields follow')
|
387
|
+
@body =<<-EOF
|
388
|
+
3000237 I am just a test article
|
389
|
+
.
|
390
|
+
EOF
|
391
|
+
@response.body = @body
|
392
|
+
@response.list.should respond_to(:each)
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
describe Net::NNTP::BodyResponse do
|
397
|
+
before do
|
398
|
+
@response = Net::NNTP::BodyResponse.new(@request, '222', '3000237 <1234@example.org>')
|
399
|
+
@body =<<EOF
|
400
|
+
This is just a test article
|
401
|
+
.
|
402
|
+
EOF
|
403
|
+
end
|
404
|
+
it_should_behave_like 'Multiline Responses'
|
405
|
+
it_should_behave_like 'Article Responses'
|
406
|
+
it_should_behave_like 'Responses with body'
|
407
|
+
end
|
408
|
+
|
409
|
+
describe Net::NNTP::ArticleSelected do
|
410
|
+
before do
|
411
|
+
@response = Net::NNTP::ArticleSelected.new(@request, '223', '3000237 <1234@example.org> retrieved')
|
412
|
+
end
|
413
|
+
it_should_behave_like 'Single Line Responses'
|
414
|
+
it_should_behave_like 'Article Responses'
|
415
|
+
end
|
416
|
+
|
417
|
+
describe Net::NNTP::OverviewInformation do
|
418
|
+
before do
|
419
|
+
@response = Net::NNTP::OverviewInformation.new(@request, '224', 'Overview Information follows')
|
420
|
+
@body = "3000234 I am just a test article \"Demo User\" <nobody@example.com> 6 Oct 1998 04:38:40 -0500 <45223423@example.com> <45454@example.net> 1234 17 Xref: news.example.com misc.test:3000363"
|
421
|
+
@response.body = @body
|
422
|
+
end
|
423
|
+
it_should_behave_like 'Multiline Responses'
|
424
|
+
it_should_behave_like 'Responses with body'
|
425
|
+
|
426
|
+
it 'should have a from field' do
|
427
|
+
@response.from.should == '"Demo User" <nobody@example.com>'
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should have a number field' do
|
431
|
+
@response.number.should == 3000234
|
432
|
+
end
|
433
|
+
|
434
|
+
|
435
|
+
it 'should have a date field' do
|
436
|
+
@response.date.should == DateTime.parse('6 Oct 1998 04:38:40 -0500')
|
437
|
+
end
|
438
|
+
|
439
|
+
it 'should have a message-id field' do
|
440
|
+
@response.message_id.should == '<45223423@example.com>'
|
441
|
+
end
|
442
|
+
|
443
|
+
it 'should have a references field' do
|
444
|
+
@response.references.should == ['<45454@example.net>']
|
445
|
+
end
|
446
|
+
|
447
|
+
it 'should have a bytes field' do
|
448
|
+
@response.bytes.should == 1234
|
449
|
+
end
|
450
|
+
|
451
|
+
it 'should have a lines field' do
|
452
|
+
@response.lines.should == 17
|
453
|
+
end
|
454
|
+
|
455
|
+
it 'should have optional headers' do
|
456
|
+
@response.optional_headers.should == {'xref' => 'news.example.com misc.test:3000363'}
|
457
|
+
end
|
458
|
+
|
459
|
+
end
|
460
|
+
|
461
|
+
describe Net::NNTP::HdrResponse do
|
462
|
+
before do
|
463
|
+
@response = Net::NNTP::HdrResponse.new(@request, '225', 'Header information follows')
|
464
|
+
@body = "300234\tI am just a test article\r\n300235\tAnother subject"
|
465
|
+
@response.body = @body
|
466
|
+
end
|
467
|
+
|
468
|
+
it_should_behave_like "Multiline Responses"
|
469
|
+
|
470
|
+
it 'should have a list of articles' do
|
471
|
+
@response.list.should == {300234 => 'I am just a test article', 300235 => 'Another subject'}
|
472
|
+
end
|
473
|
+
|
474
|
+
end
|
475
|
+
|
476
|
+
describe Net::NNTP::NewnewsResponse do
|
477
|
+
before do
|
478
|
+
@response = Net::NNTP::NewnewsResponse.new(@request, '230', 'List of new articles by message-id follows')
|
479
|
+
@body = "<1234@example.com>\r\n<3453@example.com>\r\n<4567@example.com>"
|
480
|
+
@response.body = @body
|
481
|
+
end
|
482
|
+
|
483
|
+
it_should_behave_like "Multiline Responses"
|
484
|
+
|
485
|
+
it 'should have a list of message ids' do
|
486
|
+
@response.list.should == %w[<1234@example.com> <3453@example.com> <4567@example.com>]
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
describe Net::NNTP::NewgroupsResponse do
|
491
|
+
before do
|
492
|
+
@request = Net::NNTP::Newgroups.new('20080527133122')
|
493
|
+
@response = Net::NNTP::NewgroupsResponse.new(@request, '231', 'List of new newsgroups follows')
|
494
|
+
@body = "at.test 3 5 y\r\nalt.test 8 30 y\r\n"
|
495
|
+
@response.body = @body
|
496
|
+
end
|
497
|
+
|
498
|
+
it_should_behave_like "Multiline Responses"
|
499
|
+
|
500
|
+
it 'should have a list of articles' do
|
501
|
+
@response.list.should respond_to(:each)
|
502
|
+
@response.list[0].name.should == 'at.test'
|
503
|
+
@response.list[0].high.should == 5
|
504
|
+
@response.list[0].low.should == 3
|
505
|
+
@response.list[0].status.should == 'y'
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
509
|
+
describe Net::NNTP::TransferOK do
|
510
|
+
before do
|
511
|
+
@response = Net::NNTP::TransferOK.new(@request, '235', 'Article transferred OK')
|
512
|
+
end
|
513
|
+
|
514
|
+
it_should_behave_like 'Single Line Responses'
|
515
|
+
end
|
516
|
+
|
517
|
+
describe Net::NNTP::ArticleReceived do
|
518
|
+
before do
|
519
|
+
@response = Net::NNTP::ArticleReceived.new(@request, '240', 'Article received OK')
|
520
|
+
end
|
521
|
+
|
522
|
+
it_should_behave_like 'Single Line Responses'
|
523
|
+
end
|
524
|
+
|
525
|
+
describe Net::NNTP::AuthenticationAccepted do
|
526
|
+
before do
|
527
|
+
@response = Net::NNTP::AuthenticationAccepted.new(@request, '281', 'Authentication OK')
|
528
|
+
end
|
529
|
+
it_should_behave_like 'Single Line Responses'
|
530
|
+
end
|
531
|
+
|
532
|
+
describe Net::NNTP::ContinueResponse do
|
533
|
+
end
|
534
|
+
|
535
|
+
describe Net::NNTP::TransferArticle do
|
536
|
+
before do
|
537
|
+
@response = Net::NNTP::TransferArticle.new(@request, '335', 'Send it; end with <CR-LF>.<CR-LF>')
|
538
|
+
end
|
539
|
+
it_should_behave_like 'Single Line Responses'
|
540
|
+
it 'should request a body' do
|
541
|
+
@response.needs_article?.should be_true
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
describe Net::NNTP::PostArticle do
|
546
|
+
before do
|
547
|
+
@response = Net::NNTP::PostArticle.new(@request, '340', 'Send it; end with <CR-LF>.<CR-LF>')
|
548
|
+
end
|
549
|
+
it_should_behave_like 'Single Line Responses'
|
550
|
+
it 'should request a body' do
|
551
|
+
@response.needs_article?.should be_true
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
describe Net::NNTP::PasswordRequired do
|
556
|
+
before do
|
557
|
+
@response = Net::NNTP::PasswordRequired.new(@request, '381', 'Password required')
|
558
|
+
end
|
559
|
+
it_should_behave_like 'Single Line Responses'
|
560
|
+
end
|
561
|
+
|
562
|
+
describe Net::NNTP::RetryResponse do
|
563
|
+
end
|
564
|
+
|
565
|
+
describe "Generic Responses", :shared => true do
|
566
|
+
it 'must be a generic response' do
|
567
|
+
@response.should be_generic
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
describe Net::NNTP::TemporarilyUnavailable do
|
572
|
+
before do
|
573
|
+
@response = Net::NNTP::TemporarilyUnavailable.new(@request, '400', 'Temporarily unavailable')
|
574
|
+
end
|
575
|
+
it_should_behave_like 'Single Line Responses'
|
576
|
+
end
|
577
|
+
|
578
|
+
describe Net::NNTP::InternalFault do
|
579
|
+
before(:all) do
|
580
|
+
@response = Net::NNTP::InternalFault.new(@request, '403', 'Internal Failure')
|
581
|
+
end
|
582
|
+
it_should_behave_like 'Generic Responses'
|
583
|
+
end
|
584
|
+
|
585
|
+
describe Net::NNTP::GroupUnknown do
|
586
|
+
before(:all) do
|
587
|
+
@response = Net::NNTP::GroupUnknown.new(@request, '411', 'not.here is unknown')
|
588
|
+
end
|
589
|
+
it_should_behave_like 'Single Line Responses'
|
590
|
+
end
|
591
|
+
|
592
|
+
describe Net::NNTP::NoGroupSelected do
|
593
|
+
before(:all) do
|
594
|
+
@response = Net::NNTP::NoGroupSelected.new(@request, '412', 'no group selected')
|
595
|
+
end
|
596
|
+
it_should_behave_like 'Single Line Responses'
|
597
|
+
end
|
598
|
+
|
599
|
+
describe Net::NNTP::InvalidArticle do
|
600
|
+
before(:all) do
|
601
|
+
@response = Net::NNTP::InvalidArticle.new(@request, '420', 'invalid article')
|
602
|
+
end
|
603
|
+
it_should_behave_like 'Single Line Responses'
|
604
|
+
end
|
605
|
+
|
606
|
+
describe Net::NNTP::NoPreviousArticle do
|
607
|
+
before(:all) do
|
608
|
+
@response = Net::NNTP::NoPreviousArticle.new(@request, '421', 'no previous article')
|
609
|
+
end
|
610
|
+
it_should_behave_like 'Single Line Responses'
|
611
|
+
end
|
612
|
+
|
613
|
+
describe Net::NNTP::NoNextArticle do
|
614
|
+
before(:all) do
|
615
|
+
@response = Net::NNTP::NoNextArticle.new(@request, '422', 'no next article')
|
616
|
+
end
|
617
|
+
it_should_behave_like 'Single Line Responses'
|
618
|
+
end
|
619
|
+
|
620
|
+
describe Net::NNTP::InvalidNumberOrRange do
|
621
|
+
before(:all) do
|
622
|
+
@response = Net::NNTP::InvalidNumberOrRange.new(@request, '423', 'no such article')
|
623
|
+
end
|
624
|
+
it_should_behave_like 'Single Line Responses'
|
625
|
+
end
|
626
|
+
|
627
|
+
describe Net::NNTP::NoSuchMessageid do
|
628
|
+
before(:all) do
|
629
|
+
@response = Net::NNTP::NoSuchMessageid.new(@request, '430', 'no such article')
|
630
|
+
end
|
631
|
+
it_should_behave_like 'Single Line Responses'
|
632
|
+
end
|
633
|
+
|
634
|
+
describe Net::NNTP::ArticleNotWanted do
|
635
|
+
before(:all) do
|
636
|
+
@response = Net::NNTP::ArticleNotWanted.new(@request, '435', 'not wanted')
|
637
|
+
end
|
638
|
+
it_should_behave_like 'Single Line Responses'
|
639
|
+
end
|
640
|
+
|
641
|
+
describe Net::NNTP::TransferNotPossible do
|
642
|
+
before(:all) do
|
643
|
+
@response = Net::NNTP::TransferNotPossible.new(@request, '436', 'not possible')
|
644
|
+
end
|
645
|
+
it_should_behave_like 'Single Line Responses'
|
646
|
+
end
|
647
|
+
|
648
|
+
describe Net::NNTP::TransferRejected do
|
649
|
+
before(:all) do
|
650
|
+
@response = Net::NNTP::TransferRejected.new(@request, '437', 'rejected')
|
651
|
+
end
|
652
|
+
it_should_behave_like 'Single Line Responses'
|
653
|
+
end
|
654
|
+
|
655
|
+
describe Net::NNTP::PostingNotPermitted do
|
656
|
+
before(:all) do
|
657
|
+
@response = Net::NNTP::PostingNotPermitted.new(@request, '440', 'not permitted')
|
658
|
+
end
|
659
|
+
it_should_behave_like 'Single Line Responses'
|
660
|
+
end
|
661
|
+
|
662
|
+
describe Net::NNTP::PostingFailed do
|
663
|
+
before(:all) do
|
664
|
+
@response = Net::NNTP::PostingFailed.new(@request, '441', 'failed')
|
665
|
+
end
|
666
|
+
it_should_behave_like 'Single Line Responses'
|
667
|
+
end
|
668
|
+
|
669
|
+
|
670
|
+
describe Net::NNTP::AuthenticationRequired do
|
671
|
+
before(:all) do
|
672
|
+
@response = Net::NNTP::AuthenticationRequired.new(@request, '480', 'Authentication Required')
|
673
|
+
end
|
674
|
+
it_should_behave_like 'Generic Responses'
|
675
|
+
end
|
676
|
+
|
677
|
+
describe Net::NNTP::AuthenticationRequired do
|
678
|
+
before(:all) do
|
679
|
+
@response = Net::NNTP::AuthenticationRequired.new(@request, '481', 'Authentication failed')
|
680
|
+
end
|
681
|
+
it_should_behave_like 'Single Line Responses'
|
682
|
+
end
|
683
|
+
|
684
|
+
describe Net::NNTP::AuthenticationOutOfSequence do
|
685
|
+
before(:all) do
|
686
|
+
@response = Net::NNTP::AuthenticationOutOfSequence.new(@request, '482', 'Authentication out of sequence')
|
687
|
+
end
|
688
|
+
it_should_behave_like 'Single Line Responses'
|
689
|
+
end
|
690
|
+
|
691
|
+
describe Net::NNTP::PrivacyRequired do
|
692
|
+
before(:all) do
|
693
|
+
@response = Net::NNTP::PrivacyRequired.new(@request, '483', 'Privacy Required')
|
694
|
+
end
|
695
|
+
it_should_behave_like 'Generic Responses'
|
696
|
+
end
|
697
|
+
|
698
|
+
describe Net::NNTP::NotImplemented do
|
699
|
+
before(:all) do
|
700
|
+
@response = Net::NNTP::NotImplemented.new(@request, '500', 'Not Implemented')
|
701
|
+
end
|
702
|
+
it_should_behave_like 'Generic Responses'
|
703
|
+
end
|
704
|
+
|
705
|
+
describe Net::NNTP::SyntaxError do
|
706
|
+
before(:all) do
|
707
|
+
@response = Net::NNTP::SyntaxError.new(@request, '501', 'Syntax Error')
|
708
|
+
end
|
709
|
+
it_should_behave_like 'Generic Responses'
|
710
|
+
end
|
711
|
+
|
712
|
+
describe Net::NNTP::PermanentlyUnavailable do
|
713
|
+
before(:all) do
|
714
|
+
@response = Net::NNTP::PermanentlyUnavailable.new(@request, '502', 'Permanently Unavailable')
|
715
|
+
end
|
716
|
+
it_should_behave_like 'Generic Responses'
|
717
|
+
end
|
718
|
+
|
719
|
+
describe Net::NNTP::FeatureNotProvided do
|
720
|
+
before(:all) do
|
721
|
+
@response = Net::NNTP::FeatureNotProvided.new(@request, '503', 'Feature NotProvided')
|
722
|
+
end
|
723
|
+
it_should_behave_like 'Generic Responses'
|
724
|
+
end
|
725
|
+
|
726
|
+
describe Net::NNTP::EncodingError do
|
727
|
+
before(:all) do
|
728
|
+
@response = Net::NNTP::EncodingError.new(@request, '504', 'Encoding Error')
|
729
|
+
end
|
730
|
+
it_should_behave_like 'Generic Responses'
|
731
|
+
end
|
732
|
+
|
733
|
+
describe Net::NNTP::FailResponse do
|
734
|
+
end
|
735
|
+
|
736
|
+
describe Net::NNTP::Response do
|
737
|
+
|
738
|
+
before do
|
739
|
+
@request = Net::NNTP::Help.new
|
740
|
+
end
|
741
|
+
it 'should have a request accessor' do
|
742
|
+
@request = Net::NNTP::Help.new
|
743
|
+
@response = Net::NNTP::Response.new(@request, '100', 'Help Information follows', true, false)
|
744
|
+
@response.request.should == @request
|
745
|
+
end
|
746
|
+
|
747
|
+
it 'should not request an article body' do
|
748
|
+
@response = Net::NNTP::Response.new(@request, '100', 'Help Information follows', true, false)
|
749
|
+
@response.needs_article?.should be_false
|
750
|
+
end
|
751
|
+
|
752
|
+
it 'should not request closing of the socket' do
|
753
|
+
@response = Net::NNTP::Response.new(@request, '100', 'Help Information follows', true, false)
|
754
|
+
@response.force_close?.should be_false
|
755
|
+
end
|
756
|
+
|
757
|
+
it 'should be comparable to another Response' do
|
758
|
+
Net::NNTP::Response.create(@request, '500 Not Implemented').should == Net::NNTP::Response.create(@request, '500 Not Implemented')
|
759
|
+
Net::NNTP::NotImplemented.new(@request, '500', 'Not Implemented').should_not == Net::NNTP::SyntaxError.new(@request, '500', 'Not Implemented')
|
760
|
+
end
|
761
|
+
|
762
|
+
it 'should create a NotImplemented Class' do
|
763
|
+
Net::NNTP::Response.create(@request, '500 Not Implemented').class.should == Net::NNTP::NotImplemented
|
764
|
+
end
|
765
|
+
|
766
|
+
it 'should create a SyntaxError Class' do
|
767
|
+
Net::NNTP::Response.create(@request, '501 Syntax Error').class.should == Net::NNTP::SyntaxError
|
768
|
+
end
|
769
|
+
|
770
|
+
it 'should create a PermanentlyUnavailable Class' do
|
771
|
+
Net::NNTP::Response.create(@request, '502 Feature Not Provided').class.should == Net::NNTP::PermanentlyUnavailable
|
772
|
+
end
|
773
|
+
|
774
|
+
it 'should create a FeatureNotProvided Class' do
|
775
|
+
Net::NNTP::Response.create(@request, '503 Feature Not Provided').class.should == Net::NNTP::FeatureNotProvided
|
776
|
+
end
|
777
|
+
|
778
|
+
it 'should create an EncodingError Class' do
|
779
|
+
Net::NNTP::Response.create(@request, '504 Encoding Error').class.should == Net::NNTP::EncodingError
|
780
|
+
end
|
781
|
+
|
782
|
+
it 'should create a TemporarilyUnavailable Class' do
|
783
|
+
Net::NNTP::Response.create(@request, '400 Temporarily unavailable').class.should == Net::NNTP::TemporarilyUnavailable
|
784
|
+
end
|
785
|
+
|
786
|
+
it 'should create an InternalFault Class' do
|
787
|
+
Net::NNTP::Response.create(@request, '403 Internal Error').class.should == Net::NNTP::InternalFault
|
788
|
+
end
|
789
|
+
|
790
|
+
it 'should create a GroupUnknown Class' do
|
791
|
+
@request = Net::NNTP::Group.new('not.here')
|
792
|
+
Net::NNTP::Response.create(@request, '411 not.here is unknown').class.should == Net::NNTP::GroupUnknown
|
793
|
+
end
|
794
|
+
|
795
|
+
it 'should create a NoGroupSelected Class' do
|
796
|
+
@request = Net::NNTP::Next
|
797
|
+
Net::NNTP::Response.create(@request, '412 no newsgroup selected').class.should == Net::NNTP::NoGroupSelected
|
798
|
+
end
|
799
|
+
|
800
|
+
it 'should create an InvalidArticle Class' do
|
801
|
+
@request = Net::NNTP::Article.new(0)
|
802
|
+
Net::NNTP::Response.create(@request, '420 invalid article number').class.should == Net::NNTP::InvalidArticle
|
803
|
+
end
|
804
|
+
|
805
|
+
it 'should create a NoNextArticle Class' do
|
806
|
+
Net::NNTP::Response.create(@request, '421 no next article in group').class.should == Net::NNTP::NoNextArticle
|
807
|
+
end
|
808
|
+
|
809
|
+
it 'should create a NoPreviousArticle Class' do
|
810
|
+
Net::NNTP::Response.create(@request, '422 no previous article in group').class.should == Net::NNTP::NoPreviousArticle
|
811
|
+
end
|
812
|
+
|
813
|
+
it 'should create an InvalidNumberOrRange Class' do
|
814
|
+
Net::NNTP::Response.create(@request, '423 no article with that number or in that range').class.should == Net::NNTP::InvalidNumberOrRange
|
815
|
+
end
|
816
|
+
|
817
|
+
it 'should create a NoSuchMessageid Class' do
|
818
|
+
Net::NNTP::Response.create(@request, '430 no article with that message-id').class.should == Net::NNTP::NoSuchMessageid
|
819
|
+
end
|
820
|
+
|
821
|
+
it 'should create an ArticleNotWanted Class' do
|
822
|
+
Net::NNTP::Response.create(@request, '435 article not wanted').class.should == Net::NNTP::ArticleNotWanted
|
823
|
+
end
|
824
|
+
|
825
|
+
it 'should create a TransferNotPossible Class' do
|
826
|
+
Net::NNTP::Response.create(@request, '436 transfer failed').class.should == Net::NNTP::TransferNotPossible
|
827
|
+
end
|
828
|
+
|
829
|
+
it 'should create an TransferRejected Class' do
|
830
|
+
Net::NNTP::Response.create(@request, '437 transfer rejected').class.should == Net::NNTP::TransferRejected
|
831
|
+
end
|
832
|
+
|
833
|
+
it 'should create a PostingNotPermitted Class' do
|
834
|
+
Net::NNTP::Response.create(@request, '440 not permitted').class.should == Net::NNTP::PostingNotPermitted
|
835
|
+
end
|
836
|
+
|
837
|
+
it 'should create a PostingFailed Class' do
|
838
|
+
Net::NNTP::Response.create(@request, '441 posting failed').class.should == Net::NNTP::PostingFailed
|
839
|
+
end
|
840
|
+
|
841
|
+
it 'should create a AuthenticationRequired Class' do
|
842
|
+
Net::NNTP::Response.create(@request, '480 Authentication Required').class.should == Net::NNTP::AuthenticationRequired
|
843
|
+
end
|
844
|
+
|
845
|
+
it 'should create a AuthenticationFailed Class' do
|
846
|
+
Net::NNTP::Response.create(@request, '481 Authentication failed').class.should == Net::NNTP::AuthenticationFailed
|
847
|
+
end
|
848
|
+
|
849
|
+
it 'should create a AuthenticationOutOfSequence Class' do
|
850
|
+
Net::NNTP::Response.create(@request, '482 Authentication out of sequence').class.should == Net::NNTP::AuthenticationOutOfSequence
|
851
|
+
end
|
852
|
+
|
853
|
+
it 'should create a PrivacyRequired Class' do
|
854
|
+
Net::NNTP::Response.create(@request, '483 Privacy Required').class.should == Net::NNTP::PrivacyRequired
|
855
|
+
end
|
856
|
+
|
857
|
+
it 'should create a HelpResponse Class' do
|
858
|
+
Net::NNTP::Response.create(@request, '100 Help text follows').class.should == Net::NNTP::HelpResponse
|
859
|
+
end
|
860
|
+
|
861
|
+
it 'should create a CapabilityList Class' do
|
862
|
+
Net::NNTP::Response.create(@request, '101 Capability list:').class.should == Net::NNTP::CapabilityList
|
863
|
+
end
|
864
|
+
|
865
|
+
it 'should create a DateResponse Class' do
|
866
|
+
Net::NNTP::Response.create(@request, '111 20080815124533').class.should == Net::NNTP::DateResponse
|
867
|
+
end
|
868
|
+
|
869
|
+
it 'should create a PostingAllowed Class' do
|
870
|
+
@request = Net::NNTP::Modereader.new
|
871
|
+
response = Net::NNTP::Response.create(@request, '200 Posting allowed')
|
872
|
+
response.class.should == Net::NNTP::PostingAllowed
|
873
|
+
end
|
874
|
+
|
875
|
+
it 'should create a PostingProhibited Class' do
|
876
|
+
@request = Net::NNTP::Modereader.new
|
877
|
+
response = Net::NNTP::Response.create(@request, '201 Posting Prohibited')
|
878
|
+
response.class.should == Net::NNTP::PostingProhibited
|
879
|
+
end
|
880
|
+
|
881
|
+
it 'should create a ConnectionClosing Class' do
|
882
|
+
@request = Net::NNTP::Quit.new
|
883
|
+
response = Net::NNTP::Response.create(@request, '205 Connection closing')
|
884
|
+
response.class.should == Net::NNTP::ConnectionClosing
|
885
|
+
end
|
886
|
+
|
887
|
+
it 'should create a GroupSelected Class' do
|
888
|
+
@request = Net::NNTP::Group.new('misc.test')
|
889
|
+
response = Net::NNTP::Response.create(@request, '211 1234 3000234 3002322 misc.test')
|
890
|
+
response.class.should == Net::NNTP::GroupSelected
|
891
|
+
@request = Net::NNTP::Listgroup.new('misc.test')
|
892
|
+
response = Net::NNTP::Response.create(@request, '211 1234 3000234 3002322 misc.test list follows')
|
893
|
+
response.class.should == Net::NNTP::GroupSelected
|
894
|
+
end
|
895
|
+
|
896
|
+
it 'should create a ListInformationFollows Class' do
|
897
|
+
@request = Net::NNTP::List.new
|
898
|
+
response = Net::NNTP::Response.create(@request, '215 list information follows')
|
899
|
+
response.class.should == Net::NNTP::ListInformationFollows
|
900
|
+
end
|
901
|
+
|
902
|
+
it 'should create an ArticleResponse Class' do
|
903
|
+
@request = Net::NNTP::Article.new
|
904
|
+
response = Net::NNTP::Response.create(@request, '220 Article follows')
|
905
|
+
response.class.should == Net::NNTP::ArticleResponse
|
906
|
+
end
|
907
|
+
|
908
|
+
it 'should create a HeaderResponse Class' do
|
909
|
+
@request = Net::NNTP::Head.new
|
910
|
+
response = Net::NNTP::Response.create(@request, '221 Header information follows')
|
911
|
+
response.class.should == Net::NNTP::HeaderResponse
|
912
|
+
end
|
913
|
+
|
914
|
+
it 'should create a BodyResponse Class' do
|
915
|
+
@request = Net::NNTP::Body.new
|
916
|
+
response = Net::NNTP::Response.create(@request, '222 Article Body follows')
|
917
|
+
response.class.should == Net::NNTP::BodyResponse
|
918
|
+
end
|
919
|
+
|
920
|
+
it 'should create an ArticleSelected Class' do
|
921
|
+
@request = Net::NNTP::Next.new
|
922
|
+
response = Net::NNTP::Response.create(@request, '223 3000237 <1234@example.org> retrieved')
|
923
|
+
response.class.should == Net::NNTP::ArticleSelected
|
924
|
+
end
|
925
|
+
|
926
|
+
it 'should create an OverviewInformation Class' do
|
927
|
+
@request = Net::NNTP::Over.new
|
928
|
+
response = Net::NNTP::Response.create(@request, '224 Overview Information follows')
|
929
|
+
response.class.should == Net::NNTP::OverviewInformation
|
930
|
+
end
|
931
|
+
|
932
|
+
it 'should create a HdrResponse Class' do
|
933
|
+
@request = Net::NNTP::Hdr.new('Subject')
|
934
|
+
response = Net::NNTP::Response.create(@request, '225 Header information follows')
|
935
|
+
response.class.should == Net::NNTP::HdrResponse
|
936
|
+
end
|
937
|
+
|
938
|
+
it 'should create a NewnewsResponse Class' do
|
939
|
+
@request = Net::NNTP::Newnews.new(['at.*'], '20080527 092535')
|
940
|
+
response = Net::NNTP::Response.create(@request, '230 List of new articles by message-id follows')
|
941
|
+
response.class.should == Net::NNTP::NewnewsResponse
|
942
|
+
end
|
943
|
+
|
944
|
+
it 'should create a NewgroupsResponse Class' do
|
945
|
+
@request = Net::NNTP::Newgroups.new('20080527 092535')
|
946
|
+
response = Net::NNTP::Response.create(@request, '231 List of new newsgroups follows')
|
947
|
+
response.class.should == Net::NNTP::NewgroupsResponse
|
948
|
+
end
|
949
|
+
|
950
|
+
it 'should create a TransferOK Class' do
|
951
|
+
@request = Net::NNTP::Ihave.new('<my.msgid@example.com>')
|
952
|
+
response = Net::NNTP::Response.create(@request, '235 Article transferred OK')
|
953
|
+
response.class.should == Net::NNTP::TransferOK
|
954
|
+
end
|
955
|
+
|
956
|
+
it 'should create an ArticleReceived Class' do
|
957
|
+
@request = Net::NNTP::Post.new
|
958
|
+
response = Net::NNTP::Response.create(@request, '240 Article received OK')
|
959
|
+
response.class.should == Net::NNTP::ArticleReceived
|
960
|
+
end
|
961
|
+
|
962
|
+
it 'should create an AuthenticationAccepted Class' do
|
963
|
+
@request = Net::NNTP::Authinfo.new('user', 'pass')
|
964
|
+
response = Net::NNTP::Response.create(@request, '281 Authentication OK')
|
965
|
+
response.class.should == Net::NNTP::AuthenticationAccepted
|
966
|
+
end
|
967
|
+
|
968
|
+
it 'should create a TransferArticle Class' do
|
969
|
+
@request = Net::NNTP::Ihave.new('<my.msgid@example.com>')
|
970
|
+
response = Net::NNTP::Response.create(@request, '335 Send it; end with <CR-LF>.<CR-LF>')
|
971
|
+
response.class.should == Net::NNTP::TransferArticle
|
972
|
+
end
|
973
|
+
|
974
|
+
it 'should create a PostArticle Class' do
|
975
|
+
@request = Net::NNTP::Post.new
|
976
|
+
response = Net::NNTP::Response.create(@request, '340 Send it; end with <CR-LF>.<CR-LF>')
|
977
|
+
response.class.should == Net::NNTP::PostArticle
|
978
|
+
end
|
979
|
+
|
980
|
+
it 'should create a PasswordRequired Class' do
|
981
|
+
response = Net::NNTP::Response.create(@request,'381 Password required')
|
982
|
+
response.class.should == Net::NNTP::PasswordRequired
|
983
|
+
end
|
984
|
+
|
985
|
+
it 'should create a InformationResponse on unknown 189 code' do
|
986
|
+
@request = Net::NNTP::Help.new
|
987
|
+
response = Net::NNTP::Response.create(@request, '189 unknown code')
|
988
|
+
response.class.should == Net::NNTP::InformationResponse
|
989
|
+
response.code.should == '189'
|
990
|
+
response.message.should == 'unknown code'
|
991
|
+
end
|
992
|
+
|
993
|
+
end
|
994
|
+
|