title: Devise Rspec registration controller test failing on update as if it was trying to confirm email address
body: <p>I have the following route:</p>
  
  <pre><code>devise_for :users, :controllers =&gt; { :omniauth_callbacks =&gt; "users/omniauth_callbacks",
                                       :registrations =&gt; 'users/registrations',
                                       :sessions =&gt; "users/sessions" }
  </code></pre>
  
  <p>and the following controller test (registrations_controller_spec.rb):</p>
  
  <pre><code>require File.dirname(__FILE__) + '/../spec_helper'
  
  describe Users::RegistrationsController do
    include Devise::TestHelpers
    fixtures :all
    render_views
  
    before(:each) do
      @request.env["devise.mapping"] = Devise.mappings[:user]
    end
  
    describe "POST 'create'" do
  
      describe "success" do
        before(:each) do
          @attr = { :email =&gt; "user@example.com",
                    :password =&gt; "foobar01", :password_confirmation =&gt; "foobar01", :display_name =&gt; "New User" }
        end
  
        it "should create a user" do
          lambda do
            post :create, :user =&gt; @attr
            response.should redirect_to(root_path)
          end.should change(User, :count).by(1)
        end
  
      end
  
    end
  
    describe "PUT 'update'" do
      before(:each) do
        @user = FactoryGirl.create(:user)
        @user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the confirmable module
        sign_in @user
      end
  
      describe "Success" do
  
        it "should change the user's display name" do
          @attr = { :email =&gt; @user.email, :display_name =&gt; "Test", :current_password =&gt; @user.password }
          put :update, :id =&gt; @user, :user =&gt; @attr
          puts @user.errors.messages
          @user.display_name.should == @attr[:display_name]
        end
  
      end
    end
  
  end
  </code></pre>
  
  <p>Now, when I run rspec spec I get (what I think) are weird results:</p>
  
  <p>The "should create a user" test passes. The user count has increased by 1.</p>
  
  <p>However, my "should change the user's display name" fails as follows:</p>
  
  <pre><code>1) Users::RegistrationsController PUT 'update' Success should change the user's display name
       Failure/Error: @user.display_name.should == @attr[:display_name]
         expected: "Test"
              got: "Boyd" (using ==)
  </code></pre>
  
  <p>And the weird bit is that my statement:</p>
  
  <pre><code>puts @user.errors.messages
  </code></pre>
  
  <p>Renders the following message:</p>
  
  <pre><code>{:email=&gt;["was already confirmed, please try signing in"]}
  </code></pre>
  
  <p>What's going on? The user is signed in! That's proved by the fact that the Rspec error returned the display_name of "Boyd". And why is it displaying a message looks as though it's related with account confirmation as opposed to updating a user's details?</p>
  
  <p>Any help would be greatly appreciated!</p>