# ri > Rack::MockRequest

---
type: CommandReference
command: Rack::MockRequest
mode: ri
section: 
source: ri
---

## Quick Reference

- `Rack::MockRequest.new(app)` — create a mock request wrapper
- `mock.get(uri, opts={})` — simulate GET
- `mock.post(uri, opts={})` — simulate POST
- `mock.put(uri, opts={})` — simulate PUT
- `mock.patch(uri, opts={})` — simulate PATCH
- `mock.delete(uri, opts={})` — simulate DELETE
- `mock.request(method, uri, opts={})` — generic request

## Name

`Rack::MockRequest` — helps testing your Rack application without actually using HTTP.

## Synopsis

ruby
Rack::MockRequest.new(app).get(uri, opts) => Rack::MockResponse
Rack::MockRequest.new(app).post(uri, opts) => Rack::MockResponse
## Options

The following options can be passed as a hash to `get`/`post`/`put`/`patch`/`delete`/`head`/`options`/`request`:

- `:input` — String or IO-like to be used as `rack.input`
- `:fatal` — Raise a `FatalWarning` if the app writes to `rack.errors`
- `:lint` — If true, wrap the application in `Rack::Lint`

## Constants

- `DEFAULT_ENV` — [not documented]

## Class Methods

- `env_for(uri, opts)` — create environment hash for a request
- `new(app)` — create a new mock request
- `parse_uri_rfc2396(uri)` — parse URI per RFC 2396

## Instance Methods

- `delete(uri, opts)` — simulate DELETE
- `get(uri, opts)` — simulate GET
- `head(uri, opts)` — simulate HEAD
- `options(uri, opts)` — simulate OPTIONS
- `patch(uri, opts)` — simulate PATCH
- `post(uri, opts)` — simulate POST
- `put(uri, opts)` — simulate PUT
- `request(method, uri, opts)` — generic request

## Examples

ruby
require 'rack/mock'

app = ->(env) { [200, {'Content-Type' => 'text/plain'}, ["Hello"]] }
mock = Rack::MockRequest.new(app)

response = mock.get('/')
response.status   # => 200
response.body     # => "Hello"
## See Also

- [Rack::Lint](http://localhost/phpMan.php/perldoc/Rack%3A%3ALint/markdown)
- [Rack::MockResponse](http://localhost/phpMan.php/perldoc/Rack%3A%3AMockResponse/markdown)