diff --git a/.travis.yml b/.travis.yml index 34bafb0..d10a2ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ cache: bundler matrix: include: + - rvm: 2.3 - rvm: 2.4 - rvm: 2.5 - rvm: 2.6 diff --git a/spec/protocol/http1/connection_context.rb b/spec/protocol/http1/connection_context.rb index 2e8bbd4..dbf372f 100644 --- a/spec/protocol/http1/connection_context.rb +++ b/spec/protocol/http1/connection_context.rb @@ -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