title: How do I write a helper for an integration test in Rails?
body: <p>How do I write an integration test helper that is used amongst several integration tests? I've tried the following with the following errors. I'm considering making a base class and extending that, but I don't understand how 'test_helper' is working! I can't put the helper methods in test_helper because they use special integration helpers like <code>post_with_redirect</code>. </p>
  
  <h3>LS</h3>
  
  <pre><code>$ ls test/integration
  integration_helper_test.rb  post_integration_test.rb  user_flows_test.rb
  </code></pre>
  
  <h3>Code, integration_helper_test.rb</h3>
  
  <pre><code>class IntegrationHelperTest &lt; ActionDispatch::IntegrationTest
  
    def login(user)
      ...
  </code></pre>
  
  <h3>Code, post_integration_test.rb</h3>
  
  <pre><code>require 'test_helper'
  require 'integration_helper_test'
  # require 'integration/integration_helper_test'
  
  class PostIntegrationTest &lt; ActionDispatch::IntegrationTest
    # include IntegrationHelperTest
  </code></pre>
  
  <h3>Error</h3>
  
  <pre><code>$ rake
  rake aborted!
  cannot load such file -- integration_helper_test
  C:/Users/Chloe/workspace/SeenIt/test/integration/post_integration_test.rb:2:in `&lt;top (required)&gt;'
  Tasks: TOP =&gt; test:run =&gt; test:integration
  </code></pre>
  
  <h3>Code, post_integration_test.rb</h3>
  
  <pre><code>require 'test_helper'
  # require 'integration_helper_test'
  require 'integration/integration_helper_test'
  
  class PostIntegrationTest &lt; ActionDispatch::IntegrationTest
  </code></pre>
  
  <h3>Error</h3>
  
  <pre><code>  1) Error:
  PostIntegrationTest#test_should_create_post:
  NoMethodError: undefined method `login' for #&lt;PostIntegrationTest:0x3da81d0&gt;
      test/integration/post_integration_test.rb:20:in `block in &lt;class:PostIntegrationTest&gt;'
  </code></pre>
  
  <h3>Code, post_integration_test.rb</h3>
  
  <pre><code>require 'test_helper'
  # require 'integration_helper_test'
  #require 'integration/integration_helper_test'
  
  class PostIntegrationTest &lt; ActionDispatch::IntegrationTest
    include IntegrationHelperTest
  </code></pre>
  
  <h3>Error</h3>
  
  <pre><code>$ rake
  rake aborted!
  wrong argument type Class (expected Module)
  C:/Users/Chloe/workspace/SeenIt/test/integration/post_integration_test.rb:6:in `include'
  C:/Users/Chloe/workspace/SeenIt/test/integration/post_integration_test.rb:6:in `&lt;class:PostIntegrationTest&gt;'
  C:/Users/Chloe/workspace/SeenIt/test/integration/post_integration_test.rb:5:in `&lt;top (required)&gt;'
  Tasks: TOP =&gt; test:run =&gt; test:integration
  </code></pre>
  
  <h3>test_helper.rb</h3>
  
  <pre><code>ENV["RAILS_ENV"] ||= "test"
  require File.expand_path('../../config/environment', __FILE__)
  require 'rails/test_help'
  
  class ActiveSupport::TestCase
    ActiveRecord::Migration.check_pending!
  </code></pre>