title: Rails4 + Authlogic + rspec
body: <p>Using Rails 4, I am having issues getting Authlogic to see my faked UserSession.</p>
  
  <p>I have set up pages#whoami to render the current user's email address, as a simplistic test.</p>
  
  <pre><code>class PagesController &lt; ApplicationController
    # before_filter :require_user
  
    def whoami
      render :text =&gt; current_user.try(:email) || 'anonymous'
    end
  end
  </code></pre>
  
  <p>in spec/spec_helper.rb:</p>
  
  <pre><code>require "authlogic/test_case"
  include Authlogic::TestCase
  </code></pre>
  
  <p>and my rspec test:</p>
  
  <pre><code>require 'spec_helper'
  
  describe '/whoami' do
    setup :activate_authlogic
  
    it "should tell me who I am" do
      user = FactoryGirl.create(:user)
      user.should be_valid
  
      session = UserSession.create(user)
      session.should be_valid
  
      get '/whoami'
      response.body.should == user.email
    end
  end
  </code></pre>
  
  <p>I updated my application controller to show the current session:</p>
  
  <pre><code>  def require_user
      unless current_user
  raise "Current User Session is: #{ current_user_session.inspect}"
      store_location
      flash[:notice] = "You must be logged in to access this page"
      redirect_to new_user_session_url
      return false
    end
  end
  </code></pre>
  
  <p>With before_filter :require_user commented, I correctly get "anonymous". When I uncomment it, I see that my user session is nil. I tried looking through the authlogic code but got lost in Authlogic::Session:Persistence::InstanceMethods#persisting?</p>
  
  <p>I'm trying to debug. Here's where I am so far.</p>
  
  <p>Here, we try to set Authlogic::Session::Base.controller to the test's mock controller:
  <a href="https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/test_case.rb#L109" rel="noreferrer">https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/test_case.rb#L109</a></p>
  
  <p>in my spec, I see that @controller is a Authlogic::TestCase::MockController</p>
  
  <p>and in my spec, I see that Authlogic::Session::Base.controller is set to that Mock Controller.</p>
  
  <p>However, I then check this:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    ...
  
    def current_user_session
      raise Authlogic::Session::Base.controller.inspect
      ...
    end
  end
  </code></pre>
  
  <p>and I see Authlogic::ControllerAdapters::RailsAdapter ... so somehow the controller is being set but isn't persisting. I'm wondering whether this has to do with the switch from Rails3 to Rails4?</p>
  
  <p>Any insight into this would be appreciated.</p>
  
  <p>Gem versions for those who are interested:
      gem rspec-core (2.14.5)
      gem authlogic (3.3.0)
      gem rails (4.0.0)</p>