# Rspec and restful\_authentication

**URL:** <https://www.ruby-forum.com/t/rspec-and-restful-authentication/149961>\
**Category:** Rails\
**Created:** [October 1, 2008, 6:11pm UTC](https://www.ruby-forum.com/t/rspec-and-restful-authentication/149961 "2008-10-01T18:11:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/74df32/32.png) [@Neal\_L](https://www.ruby-forum.com/u/Neal_L)\
**Post date:** [October 1, 2008, 6:11pm UTC](https://www.ruby-forum.com/t/rspec-and-restful-authentication/149961/1 "2008-10-01T18:11:07Z")

</div>

Hi all,

I’m starting to use the restful\_authenticaiton plugin in a project,  
and am using Rspec to write tests. The problem I’m having is that  
most of the app has requires that the user be logged in – i.e.,:

before\_filter :login\_required

The problem I’m running into with my Rspec tests is that I can’t quite  
figure out how to get the user logged in. I’ve read a few blog posts  
on this, but I can’t get my hands on some working test code. Has  
anyone out there run into this?

Thanks!

---

<div class="post-metadata">

**Author:** ![Neal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/74df32/32.png) [@Neal\_L](https://www.ruby-forum.com/u/Neal_L)\
**Post date:** [October 1, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/rspec-and-restful-authentication/149961/2 "2008-10-01T18:39:50Z")

</div>

Figured out my own answer here. Solution was to add

fixtures :users

at the top of the controller spec, and then

login\_as :username

in the before(:each) block of each description

… duh …
