title: Check the specific attribute of a html tag exists in Capybara with polling
body: <p>I have this simple HTML. Those attributes of buttons (Such as "AAAAA") will transit per external events. The realtime-update is executed by AJAX pooling. </p>
  
  <pre><code>&lt;div class="parent"&gt;
  &lt;div class="group"&gt;&lt;button title="AAAAA"/&gt;&lt;/div&gt;
  &lt;div class="group"&gt;&lt;button title="BBBBB"/&gt;&lt;/div&gt;
  &lt;div class="group"&gt;&lt;button title="CCCCC"/&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="parent"&gt;
  ...
  &lt;/div&gt;
  </code></pre>
  
  <p>Let's assume "AAAAA" will transit to "DDDDD" after XXX event. The test script would be like...</p>
  
  <pre><code>scenario 'test' do
      # Before change
      page.within(first('.parent')) do
          page.within(all('.group')[0]) do
              expect(page.find('button')[:title]).to include('AAAAA')
          end
          page.within(all('.group')[1]) do
              expect(page.find('button')[:title]).to include('BBBBB')
          end
          page.within(all('.group')[2]) do
              expect(page.find('button')[:title]).to include('CCCCC')
          end
      end
  
      XXX
  
      # After change (AJAX polling)
      page.within(first('.parent')) do
          page.within(all('.group')[0]) do
              expect(page.find('button')[:title]).to include('DDDDD')
          end
      end 
  end
  </code></pre>
  
  <p>However, this doesn't work. Because <code>expect(page.find('button')[:title]).to include('DDDDD')</code> won't wait until the AJAX polling executed. If I put <code>sleep(20)</code> after <code>XXX</code>, this test worked, however, that is not Capybara way, I guess.</p>
  
  <p>I'd like to know the smart way to handle this situation properly.</p>
  
  <p>Thank you for your help.</p>