-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
It would be nice if we could provide helpers for building custom rack requests. Being able to easily set request headers, the path info, the request method, the query string and the body would be nice. For example, with a request whose body is JSON, you have to do something like:
request = Rack::Request.new({
'CONTENT_TYPE' => 'application/json',
'rack.input' => StringIO.new("{ number: 1 }")
})We could pass "fake" requests using custom structs but this can get annoying the more things you depend on the request for. Also having to know rack's "structure" for headers and the body is not awesome. I think something ideal would be:
test_runner(@handler_class, {
:request => {
:headers => { 'Content-Type' => 'application/json' },
:body => "{ number: 1 }"
}
})
# OR, to avoid nesting hashes
test_runner(@handler_class, {
:request_headers => { 'Content-Type' => 'application/json' },
:request_body => "{ number: 1 }"
})Ideally, deas would handle building a StringIO for us and setting up the rack env correctly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels