title: Michael Hartl Rails Tutorial - undefined method 'sign_in'
body: <p>I'm actually stuck on Chapter 9 in Michael Hartl Rails Tutorial :
  <a href="http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#sec-unsuccessful_edits" rel="nofollow noreferrer">http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#sec-unsuccessful_edits</a></p>
  
  <p>When I run that command line :</p>
  
  <pre><code>$ bundle exec rspec spec/requests/user_pages_spec.rb -e "edit page"
  </code></pre>
  
  <p>I have that error :</p>
  
  <pre><code>Failure/Error: sign_in user
  NoMethodError: undefined method 'sign_in' for #&lt;RSpec::Core::ExampleGroupe::Nested_1::Nested_4::Nested_1:0x4e7a0b8&gt;
  </code></pre>
  
  <p>Issue come from this code in <code>spec/requests/user_pages_spec.rb</code> :</p>
  
  <pre><code>describe "edit" do
    let(:user) { FactoryGirl.create(:user) }
    before do
      sign_in user
      visit edit_user_path(user)
    end
  end
  </code></pre>
  
  <p>But <code>sign_in</code> is actually defined in <code>app/helpers/sessions_helper.rb</code> :</p>
  
  <pre><code>def sign_in(user)
    remember_token = User.new_remember_token
    cookies.permanent[:remember_token] = remember_token
    user.update_attribute(:remember_token, User.encrypt(remember_token))
    self.current_user = user
  end
  
  def signed_in?
    !current_user.nil?
  end
  
  def current_user=(user)
    @current_user = user
  end
  
  def current_user
    remember_token = User.encrypt(cookies[:remember_token])
    @current_user ||= User.find_by(remember_token: remember_token)
  end
  </code></pre>
  
  <p>And <code>SessionsHelper</code> is include in <code>app/controllers/application_controller.rb</code> :</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery with: :exception
    include SessionsHelper
  end
  </code></pre>
  
  <p>Do you have a solution?</p>