title: Import a helper function within an integration test
body: <p>I have an <strong>integration test</strong> where I need to call the <strong>log_in function</strong> (defined in Session Helper) whose parameter is a <strong>user created within a fixture</strong>. </p>
  
  <p><code>app/helpers/sessions_helper</code> </p>
  
  <pre><code>module SessionsHelper
    def log_in(user)
      session[:user_id] = user.id
    end
    .
    .
    .
  end
  </code></pre>
  
  <p>Then I have the following fixture <code>test/fixtures/user.yml</code></p>
  
  <pre><code>johndoe:
    first_name: John
    last_name: Doe
    email: john@doe.com
    password_digest: &lt;%= User.digest('password') %&gt;
  </code></pre>
  
  <p>And then the following integration test <code>test/integration/user_navigation_test</code></p>
  
  <pre><code>require 'test_helper'
  
  class UserNavigationTest &lt; ActionDispatch::IntegrationTest
  
    def setup
      @user = users(:johndoe)
    end
  
    test "login with invalid information" do
      log_in @user
    end
  
  end
  </code></pre>
  
  <p>When I run the test, I have the following error. </p>
  
  <pre><code>ERROR["test_login_with_invalid_information", UserNavigationTest, 1.2090159619983751]
   test_login_with_invalid_information#UserNavigationTest (1.21s)
  NoMethodError:         NoMethodError: undefined method `log_in' for #&lt;UserNavigationTest:0x000000065cb3f8&gt;
              test/integration/user_navigation_test.rb:10:in `block in &lt;class:UserNavigationTest&gt;'
  </code></pre>
  
  <p>I've tried to declare the log_in function within the <code>test_helper</code> but it didn't work either ; something to do with the configuration apparently. </p>
  
  <p>How can I handle this?</p>