-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2018-2024, by Samuel Williams. | ||
|
||
require "sus/fixtures/async/http" | ||
|
||
APostRequest = Sus::Shared("a post request") do | ||
include Sus::Fixtures::Async::HTTP::ServerContext | ||
|
||
let(:app) do | ||
::Protocol::HTTP::Middleware.for do |request| | ||
::Protocol::HTTP::Response[200, {}, request.body] | ||
end | ||
end | ||
|
||
it "can post a fixed length body" do | ||
body = Protocol::HTTP::Body::Buffered.wrap(["Hello, World!"]) | ||
|
||
begin | ||
response = client.post("/", body: body) | ||
|
||
expect(response).to be(:success?) | ||
expect(response.read).to be == "Hello, World!" | ||
ensure | ||
response&.finish | ||
end | ||
end | ||
end | ||
|
||
describe Async::HTTP::Protocol::HTTP10 do | ||
it_behaves_like APostRequest | ||
end | ||
|
||
describe Async::HTTP::Protocol::HTTP11 do | ||
it_behaves_like APostRequest | ||
end | ||
|
||
describe Async::HTTP::Protocol::HTTP2 do | ||
it_behaves_like APostRequest | ||
end |