Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cache: bundler

matrix:
include:
- rvm: 2.3
- rvm: 2.4
- rvm: 2.5
- rvm: 2.6
Expand Down
20 changes: 18 additions & 2 deletions spec/protocol/http1/connection_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,24 @@
require 'socket'

RSpec.shared_context Protocol::HTTP1::Connection do
let(:sockets) {Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)}

let(:sockets) {
r, w = Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)
# https://github.com/socketry/protocol-http1/pull/1#discussion_r295598266
# https://docs.ruby-lang.org/en/2.3.0/IO.html#method-i-gets
# https://docs.ruby-lang.org/en/2.5.0/IO.html#method-i-gets
if !($stdin.gets(nil, 0, chomp: true) rescue nil)
def r.gets(*args, chomp: false)
chomp ? super(*args).chomp : super(*args)
end

def w.gets(*args, chomp: false)
chomp ? super(*args).chomp : super(*args)
end
end

[r, w]
}

let(:client) {Protocol::HTTP1::Connection.new(sockets.first)}
let(:server) {Protocol::HTTP1::Connection.new(sockets.last)}
end