Skip to content

Commit

Permalink
Add better specs for HTTP_UPGRADE and rack.protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 9, 2023
1 parent e0e7bc9 commit 96def3a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/protocol/rack/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@

let(:env) {adapter.make_environment(request)}

let(:wrapped_request) {subject.new(env)}

with 'incoming rack env' do
it "can restore request from original request" do
expect(subject[env]).to be == request
end

it "can regenerate request from generic env" do
env.delete(Protocol::Rack::PROTOCOL_HTTP_REQUEST)

wrapped_request = subject[env]

expect(wrapped_request.scheme).to be == request.scheme
expect(wrapped_request.authority).to be == request.authority
expect(wrapped_request.method).to be == request.method
Expand All @@ -44,10 +42,18 @@
let(:headers) {Protocol::HTTP::Headers[{'upgrade' => 'websocket'}]}

it "can extract upgrade request" do
env.delete(Protocol::Rack::PROTOCOL_HTTP_REQUEST)

wrapped_request = subject[env]

expect(wrapped_request).to have_attributes(
protocol: be == ["websocket"]
)
end
end

with 'incoming rack env which includes rack.protocol' do
let(:request) {Protocol::HTTP::Request.new(
'https', 'example.com', 'GET', '/', 'http/1.1', headers, body, ["websocket"]
)}

it "can extract upgrade request" do
expect(wrapped_request).to have_attributes(
protocol: be == ["websocket"]
)
Expand Down

0 comments on commit 96def3a

Please sign in to comment.