Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow a Pathname to be passed as a Response body.

  • Loading branch information...
commit cbb137bf7a675c935395bae09ad97a97c2690bc6 1 parent 8035285
@benpickles authored
Showing with 6 additions and 2 deletions.
  1. +2 −2 lib/webmock/response.rb
  2. +4 −0 spec/unit/response_spec.rb
View
4 lib/webmock/response.rb
@@ -100,10 +100,10 @@ def ==(other)
private
def stringify_body!
- if @body.is_a?(IO)
+ if @body.is_a?(IO) || @body.is_a?(Pathname)
io = @body
@body = io.read
- io.close
+ io.close if io.respond_to?(:close)
end
end
View
4 spec/unit/response_spec.rb
@@ -120,6 +120,10 @@
@response.body.should == File.read(__FILE__)
end
+ it "should work with Pathnames" do
+ @response = WebMock::Response.new(:body => Pathname.new(__FILE__))
+ @response.body.should == File.read(__FILE__)
+ end
end
describe "from raw response" do
Please sign in to comment.
Something went wrong with that request. Please try again.