From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS6939 216.218.128.0/17 X-Spam-Status: No, score=1.3 required=3.0 tests=AWL,BAYES_00,RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_ZBI,RCVD_IN_XBL,RDNS_NONE,SPF_FAIL,SPF_HELO_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (unknown [216.218.222.14]) by dcvr.yhbt.net (Postfix) with ESMTP id 1FC5B1F42F for ; Thu, 21 Dec 2017 11:55:24 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH 3/6] webrick: add test for WEBrick::HTTPServlet::ERBHandler Date: Thu, 21 Dec 2017 11:55:04 +0000 Message-Id: <20171221115507.27500-4-e@80x24.org> In-Reply-To: <20171221115507.27500-1-e@80x24.org> References: <20171221115507.27500-1-e@80x24.org> List-Id: 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