lib/active_resource_integration_dsl.rb
# Logs in a user to the application via a SessionsController.  Assumes that you have
# a RESTful SessionsController with routes setup accordingly and that this is 
# how users are expected to login to your application. Pass a block to
# perform additional tests as the newly logged in user.
#
# === Requirements
# * Routes must setup new_session_path and sessions_path helper.
# * <tt>new</tt> action must provide a login form with a POST method to <tt>sessions_path</tt>
#   and text fields named <tt>user[username]</tt> and <tt>user[password]</tt>.
# * <tt>create</tt> action in controller must accept credentials in the params hash
#   in the following format.
#    {:user => {:username => 'user_login_name', :password => 'users_password'}}
# * <tt>create</tt> method must respod with a <tt>304 (Redirect)</tt> on a successfull login.
#   It doesn't matter where the redirect is to.
#
# === Usage Example
# The following will test a user loging in to the application and then performing a GET on
# the UsersController <tt>index</tt> action.
#
# 
#   def test_read_users_index
#     new_session_as('admin','password') do |admin|
#       admin.lists_users
#     end
#   end
#
Logs in a user to the application via a SessionsController.  Assumes that you have
a RESTful SessionsController with routes setup accordingly and that this is
how users are expected to login to your application. Pass a block to
perform additional tests as the newly logged in user.

Requirements
Routes must setup new_session_path and sessions_path helper.
new action must provide a login form with a POST method to sessions_path
and text fields named user[username] and user[password].
create action in controller must accept credentials in the params hash
in the following format.
{:user => {:username => 'user_login_name', :password => 'users_password'}}
create method must respod with a 304 (Redirect) on a successfull login.
It doesn't matter where the redirect is to.

Usage Example
The following will test a user loging in to the application and then performing a GET on
the UsersController index action.


Logs in a user to the application via a SessionsController . Assumes that you have a RESTful SessionsController with routes setup accordingly and that this is how users are expected to login to your application . Pass a block to perform additional tests as the newly logged in user . Requirements Routes must setup new_session_path and sessions_path helper . new action must provide a login form with a POST method to sessions_path and text fields named user [ username ] and user [ password ] . create action in controller must accept credentials in the params hash in the following format . { : user = > { : username = > ' user_login_name ' : password = > ' users_password ' }} create method must respod with a 304 ( Redirect ) on a successfull login . It doesn ' t matter where the redirect is to . Usage Example The following will test a user loging in to the application and then performing a GET on the UsersController index action .
def new_session_as(user,pass)
    new_session do |guest|
      guest.creates_session(
        :params => {
          :user => {
            :username => user,
            :password => pass
          }
        }
      ) 
      yield guest if block_given?
      guest.destroys_session('this')
    end
  end
def new_session_as ( user , pass ) new_session do | guest | guest . creates_session ( :params => { :user => { :username => user , :password => pass } } ) yield guest if block_given? guest . destroys_session ( 'this' ) end end
Logs in a user to the application via a SessionsController.
Logs in a user to the application via a SessionsController .
user
pass