Skip to content

Commit

Permalink
Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 21, 2024
1 parent 2f2a58f commit 81b26bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/protocol/http2/framer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
let(:stream) {StringIO.new}
let(:framer) {subject.new(stream)}

with "#flush" do
it "flushes the underlying stream" do
expect(stream).to receive(:flush)
framer.flush
end
end

with "#closed?" do
it "reports the status of the underlying stream" do
expect(stream).to receive(:closed?).and_return(true)
Expand Down
12 changes: 12 additions & 0 deletions test/protocol/http2/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
expect(server.state).to be == :new
end

it "fails with protocol error if first frame is not settings frame" do
framer.write_connection_preface

data_frame = Protocol::HTTP2::DataFrame.new
data_frame.pack("Hello, World!")
framer.write_frame(data_frame)

expect do
server.read_connection_preface
end.to raise_exception(Protocol::HTTP2::ProtocolError, message: be =~ /First frame must be #{Protocol::HTTP2::SettingsFrame}/)
end

it "cannot read connection preface in open state" do
server.open!
expect do
Expand Down

0 comments on commit 81b26bc

Please sign in to comment.