Sha256: 4e16c9c9e16a1523b3cb9c306966eed9599429858b4be466070f100713c72623

Contents?: true

Size: 923 Bytes

Versions: 26

Compression:

Stored size: 923 Bytes

Contents

module Webrat

  # 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.
  module MerbMultipartSupport
    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

    def multipart_post(path, params = {}, env = {})
      env[:method] = "POST"
      multipart_request(path, params, env)
    end

    def multipart_put(path, params = {}, env = {}, &block)
      env[:method] = "PUT"
      multipart_request(path, params, env)
    end
  end
end

Version data entries

26 entries across 26 versions & 9 rubygems

Version Path
dstrelau-webrat-0.5.1 lib/webrat/merb_multipart_support.rb
emipair-webrat-0.0.1 lib/webrat/merb_multipart_support.rb
garnierjm-webrat-0.4.5 lib/webrat/merb_multipart_support.rb
hardbap-webrat-0.5.1 lib/webrat/merb_multipart_support.rb
hardbap-webrat-0.5.2 lib/webrat/merb_multipart_support.rb
winton-sum-0.1.0 vendor/webrat/lib/webrat/merb_multipart_support.rb
winton-sum-0.1.1 vendor/webrat/lib/webrat/merb_multipart_support.rb
sum-0.1.1 vendor/webrat/lib/webrat/merb_multipart_support.rb
emipair-webrat-0.5.3 lib/webrat/merb_multipart_support.rb
honkster-webrat-0.4.4.2 lib/webrat/merb_multipart_support.rb
webrat-0.5.3 lib/webrat/merb_multipart_support.rb
webrat-0.5.1 lib/webrat/merb_multipart_support.rb
webrat-0.4.5 lib/webrat/merb_multipart_support.rb
webrat-0.5.0 lib/webrat/merb_multipart_support.rb
metry-2.0.4 vendor/webrat/lib/webrat/merb_multipart_support.rb
metry-2.0.5 vendor/webrat/lib/webrat/merb_multipart_support.rb
metry-2.1.0 vendor/webrat/lib/webrat/merb_multipart_support.rb
metry-2.1.1 vendor/webrat/lib/webrat/merb_multipart_support.rb
metry-2.0.0 vendor/webrat/lib/webrat/merb_multipart_support.rb
metry-2.0.1 vendor/webrat/lib/webrat/merb_multipart_support.rb