Skip to content

Commit

Permalink
Expanded coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 9, 2023
1 parent b47dae8 commit e0e7bc9
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/protocol/rack/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
let(:app) {proc{|env| [200, {}, []]}}
let(:adapter) {Protocol::Rack::Adapter.new(app)}

let(:headers) {Protocol::HTTP::Headers[{'accept' => 'text/html'}]}
let(:body) {Protocol::HTTP::Body::Buffered.new}

let(:request) {Protocol::HTTP::Request.new(
'https', 'example.com', 'GET', '/', 'http/1.1', headers, body
)}

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

with 'incoming rack env' do
let(:body) {Protocol::HTTP::Body::Buffered.new}

let(:request) {Protocol::HTTP::Request.new(
'https', 'example.com', 'GET', '/', 'http/1.1', Protocol::HTTP::Headers[{'accept' => 'text/html'}], body
)}

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

it "can restore request from original request" do
expect(subject[env]).to be == request
end
Expand All @@ -38,4 +39,18 @@
expect(wrapped_request.protocol).to be == request.protocol
end
end

with 'incoming rack env which includes HTTP upgrade' do
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
end

0 comments on commit e0e7bc9

Please sign in to comment.