Sha256: 16794b8fcc8c046ee4fb61ac408ffd86a6e423e9f53583c74be0da18535fb787
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
# encoding: utf-8 require 'spec_helper' describe HTTPkit::Serializer do shared_context :serializer do let(:yielded_chunks) { [] } let(:writer) { proc { |chunk| yielded_chunks << chunk } } subject! { described_class.new(message, writer).serialize } it 'serializes' do expect(yielded_chunks).to eq(chunks) end end describe 'with simple request' do let(:message) do HTTPkit::Request.new(:get, '/asd?k=v', { 'Key' => 'value' }, 'hello') end let(:chunks) do ["GET /asd?k=v HTTP/1.1\r\n", "Key: value\r\n\r\n", 'hello'] end include_context :serializer end describe 'with simple response' do let(:message) do HTTPkit::Response.new(200, { 'Key' => 'value' }, 'hello') end let(:chunks) do ["HTTP/1.1 200 OK\r\n", "Key: value\r\n\r\n", 'hello'] end include_context :serializer end describe 'with empty body' do let(:message) do HTTPkit::Response.new(200, 'Key' => 'value') end let(:chunks) do ["HTTP/1.1 200 OK\r\n", "Key: value\r\n\r\n", ''] end include_context :serializer end describe 'with unbounded body', reactor: true do let(:message) do HTTPkit::Response.new(200, {}, HTTPkit::Body.new) end # With a smaller body it's more difficult to test the base 16 conversion. let(:hello) { 'hello' * 204 } let(:chunks) do ["HTTP/1.1 200 OK\r\n", "\r\n", "3fc\r\n#{hello}\r\n", "0\r\n\r\n"] end before do EM.next_tick do message.body.write(hello) message.close end end include_context :serializer end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
httpkit-0.6.0 | spec/unit/serializer_spec.rb |
httpkit-0.6.0.pre.5 | spec/unit/serializer_spec.rb |