Cassius Rosenthal on 14 Jan 2008 12:03:47 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PhillyOnRails] rspec'ing authentication


I am using restful_authentication.
In spec_helper I have something like:

describe "Restricted from Anonymous", :shared => true do

 it "should be restricted for GET /index.html" do

   get :index

   response.should redirect_to( new_session_url )

 end

 it "should be restricted for GET /new.js" do

   @request.env["HTTP_ACCEPT"] = "application/javascript"

   get :new

   response.should render_template( 'sessions/new' )

 end

...

end


In my controller specs I then include something like:

describe SomeController, "access restrictions" do

 it_should_behave_like "Restricted from Anonymous"

end


This is alright for controllers that all behave in a very similar fashion (in this case, those controllers that are entirely restricted from anonymous users), but it isn't very flexible. I am increasingly frustrated that just one line in my controllers ("before_filter :login_required") is taking pages to specify in my spec files. So out of curiosity -- how do yall spec your auth'd controllers?

Thanks!
-CLR
_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk