Module: Tap::Test::HttpTest
- Defined in:
- lib/tap/test/http_test.rb
Overview
HttpTest facilitates testing of HTTP requests by initializing a Webrick server that echos requests, and providing methods to validate echoed requests.
Defined Under Namespace
Classes: EchoServer, MockServer
Class Method Summary collapse
Instance Method Summary collapse
- #default_config(log_dev = StringIO.new('')) ⇒ Object
- #web_test(app = EchoServer, config = default_config) ⇒ Object
Class Method Details
Instance Method Details
#default_config(log_dev = StringIO.new('')) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/tap/test/http_test.rb', line 42 def default_config(log_dev=StringIO.new('')) common_logger = WEBrick::Log.new(log_dev, WEBrick::Log.const_get(:WARN) ) { :Port => 2000, :Logger => common_logger, :AccessLog => common_logger } end |
#web_test(app = EchoServer, config = default_config) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tap/test/http_test.rb', line 51 def web_test(app=EchoServer, config=default_config) subset_test("WEB", "w") do begin server = ::WEBrick::HTTPServer.new(config); server.mount("/", Rack::Handler::WEBrick, app); Thread.new { server.start } yield ensure server.shutdown end end end |