process
process(action, method: "GET", params: nil, session: nil, body: nil, flash: {}, format: nil, xhr: false, as: nil)Simulate an HTTP request to action by specifying request method, parameters and set/volley the response.
-
action: The controller action to call.
-
method: Request method used to send the HTTP request. Possible values are GET, POST, PATCH, PUT, DELETE, HEAD. Defaults to GET. Can be a symbol.
-
params: The hash with HTTP parameters that you want to pass. This may be nil.
-
body: The request body with a string that is appropriately encoded (application/x-www-form-urlencoded or multipart/form-data).
-
session: A hash of parameters to store in the session. This may be nil.
-
flash: A hash of parameters to store in the flash. This may be nil.
-
format: Request format. Defaults to nil. Can be string or symbol.
-
as: Content type. Defaults to nil. Must be a symbol that corresponds to a mime type.
Example calling create action and sending two params:
process :create, method: 'POST', params: { user: { name: 'Gaurish Sharma', email: '[email protected]' } }, session: { user_id: 1 }, flash: { notice: 'This is flash message' }
To simulate GET, POST, PATCH, PUT, DELETE and HEAD requests prefer using #get, #post, #patch, #put, #delete and #head methods respectively which will make tests more expressive.
Note that the request method is not verified.