Skip to content

Commit 2cb86ec

Browse files
committed
Complete coverage for rebased changes
1 parent d9c670a commit 2cb86ec

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

‎lib/protocol/http/body/deflate.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def self.for(body, window_size = GZIP, level = DEFAULT_LEVEL)
111111
# @returns [String | Nil] the compressed chunk or `nil` if the stream is closed.
112112
def read
113113
if @stream.finished?
114-
return
114+
return nil
115115
end
116116

117117
# The stream might have been closed while waiting for the chunk to come in.

‎lib/protocol/http/body/stream.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ def read_until(pattern, offset = 0, chomp: false)
203203
split_offset = pattern.bytesize - 1
204204

205205
@buffer ||= read_next
206-
return nil if @buffer.nil?
206+
if @buffer.nil?
207+
return nil
208+
end
207209

208210
index = nil
209211
loop do

‎test/protocol/http/body/stream.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@
208208
it "can read until a pattern which isn't encountered" do
209209
expect(stream.read_until("X")).to be_nil
210210
end
211+
212+
with "empty input" do
213+
let(:input) {Protocol::HTTP::Body::Buffered.new}
214+
215+
it "returns nil" do
216+
expect(stream.read_until("X")).to be_nil
217+
end
218+
end
211219
end
212220

213221
with "#gets" do

‎test/protocol/http/request.rb‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@
136136
end
137137
end
138138

139+
with "POST request without a body" do
140+
let(:request) {subject["POST", "/submit"]}
141+
142+
it "should not be idempotent" do
143+
expect(request).not.to be(:idempotent?)
144+
end
145+
end
146+
147+
with "PUT request with a body" do
148+
let(:request) {subject["PUT", "/resource", body: "content"]}
149+
150+
it "should not be idempotent" do
151+
expect(request).not.to be(:idempotent?)
152+
end
153+
end
154+
139155
it "should have a string representation" do
140156
expect(request.to_s).to be == "http://localhost: GET /index.html HTTP/1.0"
141157
end

0 commit comments

Comments
 (0)