Reputation: 137
app.get '/namespace/controller'
works, but how can I:
Upvotes: 4
Views: 1511
Reputation: 27971
The app
object takes care of the session for you, so you don't need to worry about handling the session id manually. So, you just login, then access other pages that depend on the session being set:
app.post app.login_path, :username => "username", :password => "password"
app.get app.other_path
You can also inspect the response and session after any request, eg.:
app.response.redirect_url
app.session[:user_id] # assumes your login process uses the `user_id` key in your session
If you want, you can create a file called .irbrc
in your $HOME
directory, combining some of these ideas with something like this in it:
if Rails
def login
app.post app.login_path, :username => "username", :password => "password"
"Logged in with user_id: #{app.session[:user_id]}"
end
end
Then, in your Rails console you can just type login
to issue that method, and it will return the string showing the value of the user_id
session element.
Upvotes: 5