lib/webmock/response.rb in webmock-0.8.1 vs lib/webmock/response.rb in webmock-0.8.2
- old
+ new
@@ -1,11 +1,11 @@
module WebMock
class Response
- attr_accessor :options
+ attr_reader :options
def initialize(options = {})
- @options = options
+ self.options = options
@options[:headers] = Util::Headers.normalize_headers(@options[:headers]) unless @options[:headers].is_a?(Proc)
end
def headers
@options[:headers]
@@ -23,12 +23,16 @@
def raise_error_if_any
raise @options[:exception].new('Exception from WebMock') if @options.has_key?(:exception)
end
- def dup
+ def options=(options)
+ @options = options
stringify_body!
+ end
+
+ def dup
dup_response = super
dup_response.options = options.dup
dup_response
end
@@ -36,10 +40,12 @@
options == other.options
end
def stringify_body!
if @options[:body].is_a?(IO)
- @options[:body] = @options[:body].read
+ io = @options[:body]
+ @options[:body] = io.read
+ io.close
end
end
end
end