### Home Classes Methods

### In Files

- lib/merb-core/test/helpers/multipart_request_helper.rb
- lib/merb-core/two-oh.rb

### Namespace

- CLASS Merb::Test::MultipartRequestHelper::FileParam
- CLASS Merb::Test::MultipartRequestHelper::Param
- CLASS Merb::Test::MultipartRequestHelper::Post

### Methods

- #dispatch_multipart_to
- #multipart_fake_request
- #multipart_post
- #multipart_put
- #multipart_request

### Files

- CHANGELOG
- LICENSE
- README
- TODO

### Class/Module Index

Quicksearch

- Merb
- Merb::AbstractController
- Merb::AcceptType
- Merb::AuthenticationMixin
- Merb::AuthenticationMixin::BasicAuthentication
- Merb::BootLoader
- Merb::BootLoader::AfterAppLoads
- Merb::BootLoader::BackgroundServices
- Merb::BootLoader::BeforeAppLoads
- Merb::BootLoader::BuildFramework
- Merb::BootLoader::ChooseAdapter
- Merb::BootLoader::Cookies
- Merb::BootLoader::Defaults
- Merb::BootLoader::Dependencies
- Merb::BootLoader::DropPidFile
- Merb::BootLoader::LoadClasses
- Merb::BootLoader::Logger
- Merb::BootLoader::MimeTypes
- Merb::BootLoader::MixinSession
- Merb::BootLoader::RackUpApplication
- Merb::BootLoader::ReloadClasses
- Merb::BootLoader::ReloadClasses::TimedExecutor
- Merb::BootLoader::Router
- Merb::BootLoader::SetupSession
- Merb::BootLoader::SetupStubClasses
- Merb::BootLoader::Templates
- Merb::ConditionalGetMixin
- Merb::Config
- Merb::Config::ConfigBlock
- Merb::Const
- Merb::Controller
- Merb::ControllerExceptions
- Merb::ControllerExceptions::Accepted
- Merb::ControllerExceptions::ActionNotFound
- Merb::ControllerExceptions::BadGateway
- Merb::ControllerExceptions::BadRequest
- Merb::ControllerExceptions::Base
- Merb::ControllerExceptions::ClientError
- Merb::ControllerExceptions::Conflict
- Merb::ControllerExceptions::Continue
- Merb::ControllerExceptions::Created
- Merb::ControllerExceptions::ExpectationFailed
- Merb::ControllerExceptions::Forbidden
- Merb::ControllerExceptions::GatewayTimeout
- Merb::ControllerExceptions::Gone
- Merb::ControllerExceptions::HTTPVersionNotSupported
- Merb::ControllerExceptions::Informational
- Merb::ControllerExceptions::InternalServerError
- Merb::ControllerExceptions::LayoutNotFound
- Merb::ControllerExceptions::LengthRequired
- Merb::ControllerExceptions::MethodNotAllowed
- Merb::ControllerExceptions::MovedPermanently
- Merb::ControllerExceptions::MovedTemporarily
- Merb::ControllerExceptions::MultiPartParseError
- Merb::ControllerExceptions::MultipleChoices
- Merb::ControllerExceptions::NoContent
- Merb::ControllerExceptions::NonAuthoritativeInformation
- Merb::ControllerExceptions::NotAcceptable
- Merb::ControllerExceptions::NotFound
- Merb::ControllerExceptions::NotImplemented
- Merb::ControllerExceptions::NotModified
- Merb::ControllerExceptions::OK
- Merb::ControllerExceptions::PartialContent
- Merb::ControllerExceptions::PaymentRequired
- Merb::ControllerExceptions::PreconditionFailed
- Merb::ControllerExceptions::ProxyAuthenticationRequired
- Merb::ControllerExceptions::Redirection
- Merb::ControllerExceptions::RequestEntityTooLarge
- Merb::ControllerExceptions::RequestRangeNotSatisfiable
- Merb::ControllerExceptions::RequestTimeout
- Merb::ControllerExceptions::RequestURITooLarge
- Merb::ControllerExceptions::ResetContent
- Merb::ControllerExceptions::SeeOther
- Merb::ControllerExceptions::ServerError
- Merb::ControllerExceptions::ServiceUnavailable
- Merb::ControllerExceptions::Successful
- Merb::ControllerExceptions::SwitchingProtocols
- Merb::ControllerExceptions::TemplateNotFound
- Merb::ControllerExceptions::TemporaryRedirect
- Merb::ControllerExceptions::Unauthorized
- Merb::ControllerExceptions::UnsupportedMediaType
- Merb::ControllerExceptions::UseProxy
- Merb::ControllerMixin
- Merb::CookieSession
- Merb::CookieSession::CookieOverflow
- Merb::CookieSession::TamperedWithCookie
- Merb::Cookies
- Merb::CookiesMixin
- Merb::CookiesMixin::RequestMixin
- Merb::Counter
- Merb::Dispatcher
- Merb::Dispatcher::DefaultException
- Merb::Dispatcher::DefaultExceptionHelper
- Merb::GlobalHelpers
- Merb::InlineTemplates
- Merb::Logger
- Merb::MemcacheSession
- Merb::MemcacheStore
- Merb::MemorySession
- Merb::MemorySessionStore
- Merb::Parse
- Merb::Plugins
- Merb::Rack
- Merb::Rack::AbstractAdapter
- Merb::Rack::Adapter
- Merb::Rack::Application
- Merb::Rack::ConditionalGet
- Merb::Rack::Console
- Merb::Rack::ContentLength
- Merb::Rack::DeferrableMiddleware
- Merb::Rack::Ebb
- Merb::Rack::EventedMongrel
- Merb::Rack::FastCGI
- Merb::Rack::Handler
- Merb::Rack::Handler::Mongrel
- Merb::Rack::Head
- Merb::Rack::Helpers
- Merb::Rack::Irb
- Merb::Rack::Middleware
- Merb::Rack::Mongrel
- Merb::Rack::PathPrefix
- Merb::Rack::Profiler
- Merb::Rack::Runner
- Merb::Rack::Static
- Merb::Rack::StreamWrapper
- Merb::Rack::SwiftipliedMongrel
- Merb::Rack::Thin
- Merb::Rack::ThinTurbo
- Merb::Rack::Tracer
- Merb::Rack::WEBrick
- Merb::RenderMixin
- Merb::RenderMixin::ClassMethods
- Merb::Request
- Merb::ReservedError
- Merb::Responder
- Merb::ResponderMixin
- Merb::ResponderMixin::ClassMethods
- Merb::ResponderMixin::ContentTypeAlreadySet
- Merb::Router
- Merb::Router::Behavior
- Merb::Router::Behavior::Error
- Merb::Router::Behavior::Proxy
- Merb::Router::CachedProc
- Merb::Router::GenerationError
- Merb::Router::NotCompiledError
- Merb::Router::Resources
- Merb::Router::RouteNotFound
- Merb::Server
- Merb::Session
- Merb::SessionContainer
- Merb::SessionMixin
- Merb::SessionMixin::NoSessionContainer
- Merb::SessionMixin::RequestMixin
- Merb::SessionMixin::RequestMixin::ClassMethods
- Merb::SessionMixin::SessionOverflow
- Merb::SessionStoreContainer
- Merb::System
- Merb::System::PortablePoller
- Merb::Template
- Merb::Template::Erubis
- Merb::Template::Erubis::Mixin
- Merb::Test
- Merb::Test::ControllerHelper
- Merb::Test::Cookie
- Merb::Test::CookieJar
- Merb::Test::ExampleGroup
- Merb::Test::Helpers
- Merb::Test::MakeRequest
- Merb::Test::Matchers
- Merb::Test::MultipartRequestHelper
- Merb::Test::MultipartRequestHelper::FileParam
- Merb::Test::MultipartRequestHelper::Param
- Merb::Test::MultipartRequestHelper::Post
- Merb::Test::RequestHelper
- Merb::Test::RequestHelper::CookieJar
- Merb::Test::RequestHelper::FakeRequest
- Merb::Test::RouteHelper
- Merb::Test::Rspec
- Merb::Test::Rspec::ControllerMatchers
- Merb::Test::Rspec::ControllerMatchers::BeError
- Merb::Test::Rspec::ControllerMatchers::BeRedirect
- Merb::Test::Rspec::ControllerMatchers::Provide
- Merb::Test::Rspec::RouteMatchers
- Merb::Test::Rspec::RouteMatchers::ParameterMatcher
- Merb::Test::Rspec::RouteMatchers::RouteToMatcher
- Merb::Test::ViewHelper
- Merb::Test::WebratHelper
- Merb::Worker
- Erubis
- Erubis::Basic
- Erubis::Basic::Converter
- Erubis::BlockAwareEnhancer
- Erubis::BlockAwareEruby
- Erubis::MEruby
- Spec
- Spec::Matchers
- Spec::Matchers::MatcherDSL
- Spec::Runner
- Spec::Runner::Formatter
- Spec::Runner::Formatter::BaseTextFormatter
- Gem
- Gem::Dependency
- Hpricot
- Hpricot::Elem
- Mongrel
- Mongrel::HttpResponse
- Class
- Exception
- Hash
- Kernel
- MemCache
- Memcached
- Object
- String
- Time

No matching classes.

# Merb::Test::MultipartRequestHelper

### Public Instance Methods

dispatch_multipart_to(controller_klass, action, params = {}, env = {}, &blk) click to toggle source

Similar to dispatch_to but allows for sending files inside params.

#### Paramters

controller_klass<Controller> | The controller class object that the action should be dispatched to.
action<Symbol> | The action name, as a symbol.
params<Hash> | An optional hash that will end up as params in the controller instance.
env<Hash> | An optional hash that is passed to the fake request. Any request options should go here (see `fake_request`).
&blk | The block is executed in the context of the controller.

#### Example

    dispatch_multipart_to(MyController, :create, :my_file => @a_file ) do |controller|
      controller.stub!(:current_user).and_return(@user)
    end

#### Notes

Set your option to contain a file object to simulate file uploads.

Does not use routes.

    # File lib/merb-core/test/helpers/multipart_request_helper.rb, line 110
    def dispatch_multipart_to(controller_klass, action, params = {}, env = {}, &blk)
      request = multipart_fake_request(env, params)
      dispatch_request(request, controller_klass, action, &blk)
    end

multipart_fake_request(env = {}, params = {}) click to toggle source

#### Parameters

env<Hash> | An optional hash that is passed to the fake request. Any request options should go here (see `fake_request`).
params<Hash> | An optional hash that will end up as params in the controller instance.

#### Returns

FakeRequest | A multipart Request object that is built based on the parameters.

    # File lib/merb-core/test/helpers/multipart_request_helper.rb, line 165
    def multipart_fake_request(env = {}, params = {})
      if params.empty?
        fake_request(env)
      else
        m = Post.new(params)
        body, head = m.to_multipart
        fake_request(env.merge( :content_type => head,
                                :content_length => body.length), :post_body => body)
      end
    end

multipart_post(path, params = {}, env = {}, &block) click to toggle source

An HTTP POST request that operates through the router and uses multipart parameters.

#### Parameters

path<String> | The path that should go to the router as the request uri.
params<Hash> | An optional hash that will end up as params in the controller instance.
env<Hash> | An optional hash that is passed to the fake request. Any request options should go here (see `fake_request`).
block<Proc> | The block is executed in the context of the controller.

#### Notes

To include an uploaded file, put a file object as a value in params.

    # File lib/merb-core/test/helpers/multipart_request_helper.rb, line 129
    def multipart_post(path, params = {}, env = {}, &block)
      env[:request_method] = "POST"
      env[:test_with_multipart] = true
      mock_request(path, params, env, &block)
    end

multipart_put(path, params = {}, env = {}, &block) click to toggle source

An HTTP PUT request that operates through the router and uses multipart parameters.

#### Parameters

path<String> | The path that should go to the router as the request uri.
params<Hash> | An optional hash that will end up as params in the controller instance.
env<Hash> | An optional hash that is passed to the fake request. Any request options should go here (see `fake_request`).
block<Proc> | The block is executed in the context of the controller.

#### Notes

To include an uplaoded file, put a file object as a value in params.

    # File lib/merb-core/test/helpers/multipart_request_helper.rb, line 149
    def multipart_put(path, params = {}, env = {}, &block)
      env[:request_method] = "PUT"
      env[:test_with_multipart] = true
      mock_request(path, params, env, &block)
    end

multipart_request(path, params = {}, env = {}) click to toggle source

    # File lib/merb-core/two-oh.rb, line 3
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.