File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def force_encode_string(string, encoding)
3131 end
3232
3333 def try_encode_string ( string , encoding_name )
34- return string if encoding_name . nil?
34+ return string if encoding_name . nil? || string . nil?
3535
3636 encoding = Encoding . find ( encoding_name )
3737 return string if string . encoding == encoding
Original file line number Diff line number Diff line change @@ -149,6 +149,13 @@ def body_hash(key, value)
149149 expect ( i . response ) . to eq ( Response . new ( ResponseStatus . new ) )
150150 end
151151
152+ it 'uses a blank body if it is missing from the response' do
153+ hash [ 'response' ] [ 'body' ] = { 'encoding' => 'US-ASCII' }
154+
155+ i = HTTPInteraction . from_hash ( hash )
156+ expect ( i . response . body ) . to eq ( '' )
157+ end
158+
152159 it 'decodes the base64 body string' do
153160 hash [ 'request' ] [ 'body' ] = body_hash ( 'base64_string' , Base64 . encode64 ( 'req body' ) )
154161 hash [ 'response' ] [ 'body' ] = body_hash ( 'base64_string' , Base64 . encode64 ( 'res body' ) )
You can’t perform that action at this time.
0 commit comments