Module: Webrat::MerbMultipartSupport
- Included in:
- MerbAdapter
- Defined in:
- lib/webrat/merb_multipart_support.rb
Overview
These methods are copied from merb-core/two-oh.rb which defines new multipart_post and multipart_put methods for Merb::Test::MultipartRequestHelper. We can’t require two-oh.rb because it alters Merb’s own behavior, causing failing specs in Merb when Webrat is required.
Instance Method Summary collapse
- #multipart_post(path, params = {}, env = {}) ⇒ Object
- #multipart_put(path, params = {}, env = {}, &block) ⇒ Object
- #multipart_request(path, params = {}, env = {}) ⇒ Object
Instance Method Details
#multipart_post(path, params = {}, env = {}) ⇒ Object
17 18 19 20 |
# File 'lib/webrat/merb_multipart_support.rb', line 17 def multipart_post(path, params = {}, env = {}) env[:method] = "POST" multipart_request(path, params, env) end |
#multipart_put(path, params = {}, env = {}, &block) ⇒ Object
22 23 24 25 |
# File 'lib/webrat/merb_multipart_support.rb', line 22 def multipart_put(path, params = {}, env = {}, &block) env[:method] = "PUT" multipart_request(path, params, env) end |
#multipart_request(path, params = {}, env = {}) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/webrat/merb_multipart_support.rb', line 8 def multipart_request(path, params = {}, env = {}) multipart = Merb::Test::MultipartRequestHelper::Post.new(params) body, head = multipart.to_multipart env["CONTENT_TYPE"] = head env["CONTENT_LENGTH"] = body.size env[:input] = StringIO.new(body) request(path, env) end |