title: Rspec, Devise, Factory girl - how to sign in Factory user through Rspec controller test?
body: <p>I have a Posts controller and I have just installed Devise to add some authentication quickly and easily. Before I installed Devise, I had created some tests for the 'new' action of my Posts controller. After installing Devise, my tests were failing until i added the </p>
  
  <pre><code>config.include Devise::TestHelpers, :type =&gt; :controller
  </code></pre>
  
  <p>line to my spec_helper.rb  file. </p>
  
  <p>I also have the line</p>
  
  <pre><code>before_filter :authenticate_user!, :except =&gt; [:show, :index]
  </code></pre>
  
  <p>in my PostsController.</p>
  
  <p>Now when I run my tests, they all pass except these 2:</p>
  
  <pre><code>it "should be successful" do
       get :new
       response.should be_success
    end
  
    it "should have the right title" do
       get :new
       response.should have_selector('title', :content =&gt; @base_title + " | New post")
    end
  </code></pre>
  
  <p>I'm using Factory girl as well. The error is cause by the before_filter except parameter. I need to be able to sign in the user in rspec with a factory user. How do I sign the Factory user in from within the Rspec controller test? How do I define the Factory user?</p>
  
  <p>I have tried this in my factories.rb: </p>
  
  <pre><code>Factory.define :user do |user|  
    user.name                  "Test User"
    user.email                 "user@example.com"
    user.password              "password"
    user.password_confirmation "password"
  end
  </code></pre>
  
  <p>But then I get the error: </p>
  
  <pre><code>NoMethodError:
     undefined method `password_salt=' for #&lt;User:0x00000103cac958&gt;
  </code></pre>
  
  <p>Any help would be much appreciated. Thanks.</p>