title: assert_select not working in test
body: <p>I've scoured the internet for an answer and found nothing... this is driving me insane!</p>
  
  <p>No <code>assert_select</code> statements are working in any of my tests. I've repeatedly confirmed that the element is actually in the dom on the targeted page — and it is — but every test fails on an assert_select statement. Even one as general as <code>assert_select 'body'</code>!</p>
  
  <p><strong>Here's one test:</strong></p>
  
  <pre><code>require 'test_helper'
  
  class UsersIndexTest &lt; ActionDispatch::IntegrationTest
      def setup
          @user = users(:matt)
      end
  
      test "index including pagination" do
          log_in_as(@user)
          get users_path
          assert_template 'users/index'
          assert_select 'div.pagination'
          User.paginate(page: 1).each do |user|
              assert_select 'a[href=?]', user_path(user), text: user.first_name
          end
      end
  end
  </code></pre>
  
  <p><strong>Here's users/index.html.haml</strong></p>
  
  <pre><code>%h1 All Users
  
  = link_to 'New User', new_user_path
  
  = will_paginate
  
  %table
    %thead
      %tr
        %th
        %th First name
        %th Last name
        %th Email
        %th
        %th
        %th
  
    %tbody
      - @users.each do |user|
        %tr
          %td= gravatar_for(user)
          %td= user.first_name
          %td= user.last_name
          %td= user.email
          %td= link_to 'Show', user
          %td= link_to 'Edit', edit_user_path(user)
          %td= link_to 'Destroy', user, :method =&gt; :delete, :data =&gt; { :confirm =&gt; 'Are you sure?' }
  
  = will_paginate
  </code></pre>
  
  <p>Pretty boring stuff, right? And yet, <strong>the test fails</strong>:</p>
  
  <pre><code>FAIL["test_index_including_pagination", UsersIndexTest, 0.9574]
   test_index_including_pagination#UsersIndexTest (0.96s)
          Expected at least 1 element matching "div.pagination", found 0..
          Expected 0 to be &gt;= 1.
          test/integration/users_index_test.rb:12:in `block in &lt;class:UsersIndexTest&gt;'
  </code></pre>
  
  <p>Even when I change the assertion to <code>assert_select div</code>, it fails. And, again, I can confirm that the div is present when I visit the index page.</p>
  
  <p>What am I missing here!?!?!?!</p>
  
  <p>If it helps, here's my gemfile:</p>
  
  <pre><code>    source 'https://rubygems.org'
  
      gem 'rails',                  '4.2.0'
      gem 'pg'
      gem 'puma'
      gem 'turbolinks'
      gem 'jquery-rails'
      gem 'bcrypt',                 '~&gt; 3.1.7'
      gem 'faker',                  '~&gt; 1.4.2'
      gem 'sass-rails',             '~&gt; 5.0.1'
      gem 'bootstrap-sass',         '~&gt; 3.2.0'
      gem 'will_paginate',          '~&gt;3.0.7'
      gem 'bootstrap-will_paginate','~&gt;0.0.10'
      gem 'uglifier',               '&gt;= 2.5.0'
      gem 'haml-rails',             '~&gt; 0.8'
      gem 'jbuilder',               '~&gt; 2.2.3'
      gem 'sdoc',                   '~&gt; 0.4.0', group: :doc
      gem 'rest-client',            '~&gt; 1.7.3'
      gem 'bourbon'
  
      group :development, :test do
        gem 'byebug'
        gem 'web-console',          '~&gt; 2.0.0'
        gem 'spring'
        gem 'better_errors'
      end
  
      group :test do
        gem 'minitest-reporters',   '~&gt; 1.0.5'
        gem 'mini_backtrace',       '~&gt; 0.1.3'
        gem 'guard-minitest',       '~&gt; 2.3.1'
      end
  
      group :production do
        gem 'rails_12factor'
      end
  
      ruby '2.2.0'
  </code></pre>
  
  <p>Thanks to Steve Klein for the suggestion of printing out the response body. Unfortunately, the plot only thickens. The body clearly has the tag I'm targeting! </p>
  
  <p><strong>Added a line to the above test</strong></p>
  
  <pre><code>assert_template 'users/index'
  puts @response.body
  assert_select 'div.pagination'
  </code></pre>
  
  <p>And the output has the tag!</p>
  
  <p>&#8592; Previous</li> 1</li> <li>2</li> Next &#8594;</li></p>
  
  <p>And yet still fails!!!</p>
  
  <pre><code>FAIL["test_index_as_admin_including_pagination_and_delete_links", UsersIndexTest, 1.412393] test_index_as_admin_including_pagination_and_delete_links#UsersIndexTest (1.41s)
      Expected at least 1 element matching "div.pagination", found 0..
      Expected 0 to be &gt;= 1.
      test/integration/users_index_test.rb:15:in `block in &lt;class:UsersIndexTest&gt;'
  </code></pre>