lib/webmock/response.rb in webmock-0.8.0 vs lib/webmock/response.rb in webmock-0.8.1

- old
+ new

@@ -11,16 +11,12 @@ @options[:headers] end def body return '' unless @options.has_key?(:body) - case @options[:body] - when IO - @options[:body].read - when String - @options[:body] - end + stringify_body! + @options[:body] end def status @options.has_key?(:status) ? @options[:status] : 200 end @@ -28,16 +24,23 @@ def raise_error_if_any raise @options[:exception].new('Exception from WebMock') if @options.has_key?(:exception) end def dup + stringify_body! dup_response = super dup_response.options = options.dup dup_response end def ==(other) options == other.options + end + + def stringify_body! + if @options[:body].is_a?(IO) + @options[:body] = @options[:body].read + end end end end