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:
parent
646b83af2a
commit
1895a48856
2 changed files with 20 additions and 0 deletions
|
@ -321,4 +321,20 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
|
||||||
http.request(req, &response_assertion)
|
http.request(req, &response_assertion)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
4
test/webrick/webrick.rhtml
Normal file
4
test/webrick/webrick.rhtml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
req to <%=
|
||||||
|
servlet_request.request_uri
|
||||||
|
%> <%=
|
||||||
|
servlet_request.query.inspect %>
|
Loading…
Reference in a new issue