spec/client_spec.rb in http-2-0.8.4 vs spec/client_spec.rb in http-2-0.9.0
- old
+ new
@@ -32,10 +32,27 @@
expect(frame[:type]).to eq :settings
expect(frame[:payload]).to include([:settings_max_concurrent_streams, 200])
end
end
+ context 'upgrade' do
+ it 'fails when client has already created streams' do
+ @client.new_stream
+ expect { @client.upgrade }.to raise_error(HTTP2::Error::ProtocolError)
+ end
+
+ it 'sends the preface' do
+ expect(@client).to receive(:send_connection_preface)
+ @client.upgrade
+ end
+
+ it 'initializes the first stream in the half-closed state' do
+ stream = @client.upgrade
+ expect(stream.state).to be(:half_closed_local)
+ end
+ end
+
context 'push' do
it 'should disallow client initiated push' do
expect do
@client.promise({}) {}
end.to raise_error(NoMethodError)
@@ -67,13 +84,29 @@
s = @client.new_stream
s.send HEADERS.deep_dup
promise = nil
@client.on(:promise) { |stream| promise = stream }
- @client << set_stream_id(f.generate(PUSH_PROMISE.dup), s.id)
+ @client << set_stream_id(f.generate(PUSH_PROMISE.deep_dup), s.id)
expect(promise.id).to eq 2
expect(promise.state).to eq :reserved_remote
+ end
+
+ it 'should emit promise headers for received PUSH_PROMISE' do
+ header = nil
+ s = @client.new_stream
+ s.send HEADERS.deep_dup
+
+ @client.on(:promise) do |stream|
+ stream.on(:promise_headers) do |h|
+ header = h
+ end
+ end
+ @client << set_stream_id(f.generate(PUSH_PROMISE.deep_dup), s.id)
+
+ expect(header).to be_a(Array)
+ # expect(header).to eq([%w(a b)])
end
it 'should auto RST_STREAM promises against locally-RST stream' do
s = @client.new_stream
s.send HEADERS.deep_dup