dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 3/6] webrick: add test for WEBrick::HTTPServlet::ERBHandler
Date: Thu, 21 Dec 2017 11:55:04 +0000	[thread overview]
Message-ID: <20171221115507.27500-4-e@80x24.org> (raw)
In-Reply-To: <20171221115507.27500-1-e@80x24.org>

This previously had no coverage.

* test/webrick/test_filehandler.rb (test_erbhandler): new test
* test/webrick/webrick.rhtml: new file for test
---
 test/webrick/test_filehandler.rb | 16 ++++++++++++++++
 test/webrick/webrick.rhtml       |  4 ++++
 2 files changed, 20 insertions(+)
 create mode 100644 test/webrick/webrick.rhtml

diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb
index 0e05c6824c..3fba1ec5e2 100644
--- a/test/webrick/test_filehandler.rb
+++ b/test/webrick/test_filehandler.rb
@@ -321,4 +321,20 @@ def req.meta_vars
       http.request(req, &response_assertion)
     end
   end
+
+  def test_erbhandler
+    config = { :DocumentRoot => File.dirname(__FILE__) }
+    log_tester = lambda {|log, access_log|
+      log = log.reject {|s| /ERROR `.*\' not found\./ =~ s }
+      assert_equal([], log)
+    }
+    TestWEBrick.start_httpserver(config, log_tester) do |server, addr, port, log|
+      http = Net::HTTP.new(addr, port)
+      req = Net::HTTP::Get.new("/webrick.rhtml")
+      http.request(req) do |res|
+        assert_equal("200", res.code, log.call)
+        assert_match %r!\Areq to http://[^/]+/webrick\.rhtml {}\n!, res.body
+      end
+    end
+  end
 end
diff --git a/test/webrick/webrick.rhtml b/test/webrick/webrick.rhtml
new file mode 100644
index 0000000000..a7bbe43fb5
--- /dev/null
+++ b/test/webrick/webrick.rhtml
@@ -0,0 +1,4 @@
+req to <%=
+servlet_request.request_uri
+%> <%=
+servlet_request.query.inspect %>
-- 
EW


  parent reply	other threads:[~2017-12-21 11:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21 11:55 [PATCH 0/6] webrick: audit and fix Kernel#open misuse Eric Wong
2017-12-21 11:55 ` [PATCH 1/6] webrick: httpauth requires regular files Eric Wong
2017-12-21 11:55 ` [PATCH 2/6] webrick/httpservlet/cgi_runner.rb: remove unnecessary open Eric Wong
2017-12-21 11:55 ` Eric Wong [this message]
2017-12-21 11:55 ` [PATCH 4/6] webrick: WEBrick::Log requires path arg when given string Eric Wong
2017-12-21 11:55 ` [PATCH 5/6] webrick/httpservlet/*handler: use File.open Eric Wong
2017-12-21 11:55 ` [PATCH 6/6] webrick/httputils: note Kernel#open behavior Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171221115507.27500-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).