Devise seems to become the new authentication standard in rails land. Also the last version of the gem is for rails3, so it is very easy to start using it.
If you are using rspec2 for your tests, it is also really easy to test your controllers that are authenticated by devise.
Suppose you have a DoStuffController like this:
class DoStuffController < ApplicationController before_filter :authenticate_user! def index end end
You need to test it as follows in
require 'spec_helper' describe DoStuffController do include Devise::TestHelpers before (:each) do @user = Factory.create(:user) sign_in @user end describe "GET 'index'" do it "should be successful" do get 'index' response.should be_success end end end
And in your factory,
Factory.define :user do |f| f.email "firstname.lastname@example.org" f.password "blax123" end
I am not testing the fact that the redirect will work, under the assumption that that is specific devise functionality which i assume to be tested and working.