spec/unit/server_spec.rb in hatetepe-0.6.0.pre vs spec/unit/server_spec.rb in hatetepe-0.6.0.pre.1
- old
+ new
@@ -13,11 +13,11 @@
closed: double('closed', then: nil),
serialize: nil,
close: nil)
end
let(:handler_class) { double('handler_class', new: handler) }
- let(:handler) { double('handler', post_init: nil, respond: nil) }
+ let(:handler) { double('handler', setup: nil, respond: nil) }
describe '.start' do
specify { pending }
end
@@ -34,39 +34,43 @@
end
it 'sets up handlers' do
expect(handler_class).to have_received(:new)
.with(config, server, connection)
- expect(handler).to have_received(:post_init)
+ expect(handler).to have_received(:setup)
end
end
describe '#serve' do
- let(:request) { default_request }
- let(:response) { default_response }
+ let(:request) { open_request }
+ let(:response) { open_response }
before do
allow(server).to receive(:respond)
- allow(handler).to receive(:serve) { @fiber = Fiber.current }
+ allow(handler).to receive(:serve) { |_, served|
+ @served = served
+ @fiber = Fiber.current
+ }
end
subject! { server.serve(request) }
it 'sets up correlation' do
- request.served.fulfill(response)
+ @served.fulfill(response)
tick
expect(server).to have_received(:respond).with(request, response)
end
it 'notifies the handlers' do
- expect(handler).to have_received(:serve).with(request)
+ expect(handler).to have_received(:serve)
+ .with(request, kind_of(Hatetepe::Promise))
expect(@fiber).not_to be(Fiber.current)
end
end
describe '#respond' do
- let(:request) { default_request }
- let(:response) { default_response }
+ let(:request) { open_request }
+ let(:response) { open_response }
subject! { server.respond(request, response) }
it 'writes response to underlying connection' do
expect(connection).to have_received(:serialize).with(response)