Sha256: 4a07c1f2f1888a37cedeac9c2f5f052a1625a6c67f2ff852a1ebe9a965cb71de
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Mongrel2::Response do before(:each) do @req = double() @resp = double() @response = Mongrel2::Response.new(@resp) end it 'should build the HTTP request format' do @req.should_receive(:uuid) { 'UUID' } @req.should_receive(:conn_id) { 'CONN_ID' } httpreq = "UUID 7:CONN_ID, HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nBoo!" @resp.should_receive(:send_msg).with(httpreq) @response.send_http(@req, 'Boo!', 200, {}) end it 'should send a blank response to close the response' do @req.should_receive(:uuid) { 'UUID' } @req.should_receive(:conn_id) { 'CONN_ID' } httpreq = 'UUID 7:CONN_ID, ' @resp.should_receive(:send_msg).with(httpreq) @response.close(@req) end it 'should count bytesize of body as Content-Length' do def @response.send_resp(uuid, conn_id, data) # do nothing end @req.stub(:uuid).and_return(nil) @req.stub(:conn_id).and_return(nil) headers = {} @response.send_http @req, 'abc', 200, headers headers['Content-Length'].should eql('abc'.bytesize.to_s) @response.send_http @req, 'あいう', 200, headers headers['Content-Length'].should eql('あいう'.bytesize.to_s) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
em-rack-mongrel2-0.2.3 | spec/response_spec.rb |
em-rack-mongrel2-0.2.2 | spec/response_spec.rb |