title: Why does adding "sleep 1" in an after hook cause this Rspec/Capybara test to pass?
body: <p>I'm using rails 4.0.5, rspec 2.14.1, capybara 2.2.1, capybara-webkit 1.1.0 and database_cleaner 1.2.0.  I'm seeing some weird behavior with the following feature test (which simulates a user viewing a comment on a post, hovering over an icon to make a menu appear, and clicking a menu item to delete the comment):</p>
  
  <pre><code>let(:user){create(:user)}
  let(:post){create(:post, author: user)}
  let!(:comment){create(:comment, post: post, author: user)}
  
  ...
  
  it "can delete a comment" do
    assert(page.has_css? "#comment-#{comment.id}")
    find("#comment-#{comment.id}-controls").trigger(:mouseover)
    find("#comment-#{comment.id} .comment-delete a").click
    assert(page.has_no_css? "#comment-#{comment.id}")
  end
  </code></pre>
  
  <p>This test fails about 80% of the time, always due to some record being retrieved from the database as <code>nil</code>-- I get <code>NoMethodError: undefined method X for nil:NilClass</code>, for various values of X.  Sometimes the nil is the comment that's being deleted, sometimes it's the post that the comment's attached to, sometimes it's the author of the comment/post.</p>
  
  <p>If I add <code>sleep 1</code> to the end of the test, it passes:</p>
  
  <pre><code>it "can delete its own comment" do
    assert(page.has_css? "#comment-#{comment.id}")
    find("#comment-#{comment.id}-controls").trigger(:mouseover)
    find("#comment-#{comment.id} .comment-delete a").click
    assert(page.has_no_css? "#comment-#{comment.id}")
    sleep 1
  end
  </code></pre>
  
  <p>It also passes if I put <code>sleep 1</code> in an <code>after</code> block.</p>
  
  <p>Any idea why I get these NoMethodErrors, and/or why the test passes if I make it sleep for a second after all the work is done?</p>