Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 1.08 KB

2016-03-07-Interaction_to_app_from_console.md

File metadata and controls

36 lines (25 loc) · 1.08 KB
title tip-number tip-username tip-username-profile tip-description
Interaction with app from rails console
25
Logesh
We can interact with the app from console to imitate the real user action without a browser or server

Issuing Requests Interactively

The app object can also issue faux requests into your app, mimicing what a real user might do. We tend not to do this very often, but it can be quite useful for one-off interactions with the app from the console. The best part is that no browser or server is required.

Here's a quick test drive to give you a feel for what's possible:

>> app.get "/movies"
=> 200

>> app.get "/users/1"
=> 302

>> app.response.redirect_url
=> "http://www.example.com/session/new"

>> app.post "/session", email: '[email protected]', password: 'secret'
=> 302

>> app.response.redirect_url
=> "http://www.example.com/users/1"

>> app.session[:user_id]
=> 7

For more details on the methods you can call on the app object to issue requests, check out the ActionDispatch::Integration::RequestHelpers documentation.