1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

webrick: add test for WEBrick::HTTPServlet::ERBHandler

This previously had no coverage.

* test/webrick/test_filehandler.rb (test_erbhandler): new test
* test/webrick/webrick.rhtml: new file for test
  [Misc #14216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2017-12-22 01:07:50 +00:00
parent 646b83af2a
commit 1895a48856
2 changed files with 20 additions and 0 deletions

View file

@ -321,4 +321,20 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
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

View file

@ -0,0 +1,4 @@
req to <%=
servlet_request.request_uri
%> <%=
servlet_request.query.inspect %>