Sha256: 71f68780ddd64c43c122d68460998f3f4820e8810615e71966523a6a88a8b412
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
$:.unshift File.join(File.dirname(__FILE__),'..','..','lib') require 'evdispatch' require 'test/unit' $d = Evdispatch::Loop.new # start the event loop thread $d.start class TestRequests < Test::Unit::TestCase def test_response id = $d.request_http("http://127.0.0.1:4044/bytes/10") response = $d.response( id ) #puts response.inspect #{:response_time=>0.003444, :name=>"http://127.0.0.1:4044/bytes/10", :id=>0, :body=>"CCCCCCCCCC"} assert_equal("http://127.0.0.1:4044/bytes/10", response[:name]) assert_equal("CCCCCCCCCC", response[:body]) assert_equal("HTTP/1.1 200 OK\r\nContent-Type: text/json\r\nContent-Length: 10\r\nConnection: close\r\n\r\n", response[:header]) assert(response.keys.include?(:response_time)) assert(response.keys.include?(:id)) end def test_options_request id = $d.request("http://127.0.0.1:4044/redir/1", :followlocation => 1, :referer => 'pizza') response = $d.response( id ) assert_match(/ 302 Moved Temporarily/,response[:header]) assert_match(/ 200 OK/,response[:header]) end def test_delayed_with_flush id = $d.request("http://127.0.0.1:4044/delay/0") tid = $d.request("http://127.0.0.1:4044/delay/3") res = $d.response( id, 1.0, 1 ) res2 = $d.response( tid, 1.0, 1 ) if !res or !res2 $d.flush # flush because we aborted before we finished, still the issue of the request is still running, but any previous responses that were delayed will be flushed end puts res.inspect puts res2.inspect end end # not bothering to cleanup
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
evdispatch-0.2.2 | ext/revdispatch/stest.rb |