test/mock/mock_socket.rb in ruby-net-nntp-0.0.9 vs test/mock/mock_socket.rb in ruby-net-nntp-0.1.0

- old
+ new

@@ -103,11 +103,11 @@ @io = ["430 No such article"] end when /^list\b\s*(.*)\r\n$/ case $1 when /overview.fmt/i - @io = ["215 Order of fields in overview database.\r\nSubject:\r\nFrom:\r\nDate:\r\nMessage-ID:\r\nReferences:\r\nBytes:\r\nLines:\r\nXref:full\r\n.\r\n" ] + @io = ["215 Order of fields in overview database.\r\n", "Subject:\r\n", "From:\r\n", "Date:\r\n", "Message-ID:\r\n", "References:\r\n", "Bytes:\r\n", "Lines:\r\n", "Xref:full\r\n", ".\r\n" ] when /active\s*(.*)/ @io = ["215 Newsgroups in form \"group high low flags\".", "at.test 200 100 y\r\n", "at.linux 100 90 n\r\n", ".\r\n"] when /^\s*$/ @io = ["215 Newsgroups in form \"group high low flags\".", "at.test 200 100 y\r\n", "at.linux 100 90 n\r\n", ".\r\n"] else @@ -184,14 +184,14 @@ "1372\r\n", "1373\r\n", "1374\r\n", "1375\r\n", ".\r\n" - ] - else - if @group_selected - @io = [ + ] + else + if @group_selected + @io = [ "211 Article list for at.linux follows\r\n", "1363\r\n", "1364\r\n", "1365\r\n", "1366\r\n", @@ -203,35 +203,35 @@ "1372\r\n", "1373\r\n", "1374\r\n", "1375\r\n", ".\r\n" - ] + ] + else + @io = ['412 No Group selected'] + end + end + when "quit\r\n" then + @io = ["200 Good bye"] + when "authinfo user dummy\r\n" + @io = ["381 More authentication details needed"] + when "authinfo pass test\r\n" + @io = ["281 Welcome to dummytest"] + when /^group\s+(.+)\s*\r\n$/ + case $1 + when 'at.linux' + @io = ["211 12 1363 1375 at.linux"] + @group_selected = 'at.linux' else - @io = ['412 No Group selected'] + @io = ["411 No such group"] end - end - when "quit\r\n" then - @io = ["200 Good bye"] - when "authinfo user dummy\r\n" - @io = ["381 More authentication details needed"] - when "authinfo pass test\r\n" - @io = ["281 Welcome to dummytest"] - when /^group\s+(.+)\s*\r\n$/ - case $1 - when 'at.linux' - @io = ["211 12 1363 1375 at.linux"] - @group_selected = 'at.linux' - else - @io = ["411 No such group"] - end - when "xhdr subject <slrnf26akq.ci5.hjp-usenet2@zeno.hjp.at>\r\n" - @io = - ["1375 Re: Bitte um Meinungen ==> Virtualisierung\r\n"] - when "xhdr subject 1363-1375\r\n" - if @group_selected - @io = [ + when "xhdr subject <slrnf26akq.ci5.hjp-usenet2@zeno.hjp.at>\r\n" + @io = + ["1375 Re: Bitte um Meinungen ==> Virtualisierung\r\n"] + when "xhdr subject 1363-1375\r\n" + if @group_selected + @io = [ "221 Subject header (from overview) for postings 1363-1375\r\n", "1363 Re: Bitte um Meinungen ==> Virtualisierung\r\n", "1364 Re: Bitte um Meinungen ==> Virtualisierung\r\n", "1365 Re: Bitte um Meinungen ==> Virtualisierung\r\n", "1366 Re: Bitte um Meinungen ==> Virtualisierung\r\n", @@ -243,15 +243,15 @@ "1372 Re: Bitte um Meinungen ==> Virtualisierung\r\n", "1373 Re: Bitte um Meinungen ==> Virtualisierung\r\n", "1374 Re: Bitte um Meinungen ==> Virtualisierung\r\n", "1375 Re: Bitte um Meinungen ==> Virtualisierung\r\n", ".\r\n" - ] - else - @io = ['412 No group selected'] - end - when "xover 1363-1375\r\n" + ] + else + @io = ['412 No group selected'] + end + when "xover 1363-1375\r\n" if @group_selected @io = [ "224 Overview information for postings 1363-1375:\r\n", "1363 Re: Bitte um Meinungen ==> Virtualisierung \"Igo Besser\" <i.besser@aon.at> Sun, 15 Apr 2007 14:09:46 +0200 <46221541$0$2299$91cee783@newsreader01.highway.telekom.at> <4621dbb8$0$2310$91cee783@newsreader01.highway.telekom.at> <dh49f4-qem.ln1@this.is.a.news.server.you.goddamn.stupid.program> <slrnf23snh.dfm.hjp-usenet2@zeno.hjp.at> <4621ff58$0$2307$91cee783@newsreader01.highway.telekom.at> <evt242$1jc7$1@geiz-ist-geil.priv.at> 1165 9 Xref: sensor.twincode.net at.linux:1363\r\n", "1364 Re: Bitte um Meinungen ==> Virtualisierung \"Igo Besser\" <i.besser@aon.at> Sun, 15 Apr 2007 14:14:12 +0200 <4622164b$0$25611$91cee783@newsreader02.highway.telekom.at> <4621dbb8$0$2310$91cee783@newsreader01.highway.telekom.at> <dh49f4-qem.ln1@this.is.a.news.server.you.goddamn.stupid.program> <4621fc17$0$2315$91cee783@newsreader01.highway.telekom.at> <evt1p1$1jar$1@geiz-ist-geil.priv.at> 1229 13 Xref: sensor.twincode.net at.linux:1364\r\n", @@ -265,13 +265,13 @@ "1372 Re: Bitte um Meinungen ==> Virtualisierung Bernd Haug <haug@berndhaug.net> Sun, 15 Apr 2007 23:54:05 +0200 <tgjaf4-lt9.ln1@this.is.a.news.server.you.goddamn.stupid.program> <4621dbb8$0$2310$91cee783@newsreader01.highway.telekom.at> <dh49f4-qem.ln1@this.is.a.news.server.you.goddamn.stupid.program> <slrnf23snh.dfm.hjp-usenet2@zeno.hjp.at> <4621ff58$0$2307$91cee783@newsreader01.highway.telekom.at> <slrnf24e9s.dtb.hjp-usenet2@zeno.hjp.at> <46225c97$0$25626$91cee783@newsreader02.highway.telekom.at> <slrnf24vjv.7pk.hjp-usenet2@zeno.hjp.at> 1721 10 Xref: sensor.twincode.net at.linux:1372\r\n", "1373 Re: Bitte um Meinungen ==> Virtualisierung Wolfgang Fuschlberger <usenet-2006-05@fuschlberger.net> Sun, 15 Apr 2007 23:58:07 +0200 <fojaf4-kcj.ln1@window.dtdns.net> <4621dbb8$0$2310$91cee783@newsreader01.highway.telekom.at> <dh49f4-qem.ln1@this.is.a.news.server.you.goddamn.stupid.program> <slrnf23snh.dfm.hjp-usenet2@zeno.hjp.at> <4621ff58$0$2307$91cee783@newsreader01.highway.telekom.at> <slrnf24e9s.dtb.hjp-usenet2@zeno.hjp.at> <46225c97$0$25626$91cee783@newsreader02.highway.telekom.at> <16caf4-581.ln1@swws1.dyndns.org> <46229089$0$10578$3b214f66@tunews.univie.ac.at> 1800 17 Xref: sensor.twincode.net at.linux:1373\r\n", "1374 Re: Bitte um Meinungen ==> Virtualisierung Andreas Labres <al-nospam0310&bounce@labres.at> Mon, 16 Apr 2007 08:57:43 +0200 <1tnru1ccirb05.dlg@al.lab.at> <4621dbb8$0$2310$91cee783@newsreader01.highway.telekom.at> <dh49f4-qem.ln1@this.is.a.news.server.you.goddamn.stupid.program> <slrnf23snh.dfm.hjp-usenet2@zeno.hjp.at> <4621ff58$0$2307$91cee783@newsreader01.highway.telekom.at> 1702 19 Xref: sensor.twincode.net at.linux:1374\r\n", "1375 Re: Bitte um Meinungen ==> Virtualisierung \"Peter J. Holzer\" <hjp-usenet2@hjp.at> Mon, 16 Apr 2007 09:49:46 +0200 <slrnf26akq.ci5.hjp-usenet2@zeno.hjp.at> <4621dbb8$0$2310$91cee783@newsreader01.highway.telekom.at> <dh49f4-qem.ln1@this.is.a.news.server.you.goddamn.stupid.program> <slrnf23snh.dfm.hjp-usenet2@zeno.hjp.at> <4621ff58$0$2307$91cee783@newsreader01.highway.telekom.at> <1tnru1ccirb05.dlg@al.lab.at> 2127 33 Xref: sensor.twincode.net at.linux:1375\r\n", ".\r\n" - ] - else - @io = ["412 No Group selected"] + ] + else + @io = ["412 No Group selected"] end when /xover \<.+\>/ @io = ["502 Usage: OVER first[-[last]]"] when /^xhdr\s*$/ @io = ["502 Usage: HDR header [first[-last]]|[message-id]"] @@ -298,15 +298,15 @@ "NNTP-Posting-Host: 6cf11d8c.newsspool1.arcor-online.net\r\n", "X-Trace: DXC=Cd=D_AR>:`a^Y=RbYBPl4`ic==]BZ:afn4Fo<]lROoRaFl8W>\BH3Yb7K@fQgPi`FgUTEAfnAR\Ta@JWJ8E:^d<ob]cIfD6hVgh<SdIn0f]3?i\r\n", "X-Complaints-To: usenet-abuse@arcor.de\r\n", "Xref: sensor.twincode.net at.linux:1430\r\n", ".\r\n" - ] + ] when /^\s?$/ - if @group_selected - @io = [ + if @group_selected + @io = [ "221 1430 <462dfa6f$0$23135$9b4e6d93@newsspool1.arcor-online.net> article retrieved - head follows\r\n", "Path: vietwist00.chello.at!newsfeed02.chello.at!newsfeed01.chello.at!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail\r\n", "Message-ID: <462dfa6f$0$23135$9b4e6d93@newsspool1.arcor-online.net>\r\n", "From: Gerhard Engler <gerhard.engler@gmx.de>\r\n", "Newsgroups: at.linux\r\n", @@ -324,22 +324,22 @@ "NNTP-Posting-Host: 6cf11d8c.newsspool1.arcor-online.net\r\n", "X-Trace: DXC=Cd=D_AR>:`a^Y=RbYBPl4`ic==]BZ:afn4Fo<]lROoRaFl8W>\BH3Yb7K@fQgPi`FgUTEAfnAR\Ta@JWJ8E:^d<ob]cIfD6hVgh<SdIn0f]3?i\r\n", "X-Complaints-To: usenet-abuse@arcor.de\r\n", "Xref: sensor.twincode.net at.linux:1430\r\n", ".\r\n" - ] - else - @io = ["412 No Group selected"] - end + ] + else + @io = ["412 No Group selected"] + end else @io = ["501 Bad Command"] end - else - @io = ["500 Unknown Command"] - end - return str.length + else + @io = ["500 Unknown Command"] end + return str.length + end def readline super @io.shift end @@ -347,6 +347,6 @@ private def dp(x) $stdout.puts x end - end +end