title: How can I use assert_select in a Rails functional test to check for multiple elements of the same type, differing only by text?
body: <p>I have a Rails view that outputs HTML similar to this:</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;h1&gt;Keywords&lt;/h1&gt;
  
      &lt;h2&gt;EN&lt;/h2&gt;
      &lt;h3&gt;Accepted&lt;/h3&gt;
      &lt;ul&gt;
        &lt;li&gt;Foo&lt;/li&gt;
      &lt;/ul&gt;
      &lt;h3&gt;Rejected&lt;/h3&gt;
      &lt;ul&gt;
        &lt;li&gt;Bar&lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;h2&gt;SV&lt;/h2&gt;
      &lt;h3&gt;Accepted&lt;/h3&gt;
      &lt;ul&gt;
        &lt;li&gt;Föö&lt;/li&gt;
      &lt;/ul&gt;
      &lt;h3&gt;Rejected&lt;/h3&gt;
      &lt;ul&gt;
        &lt;li&gt;Bär&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'd like to use <code>assert_select</code> to ensure that I have <code>&lt;h2&gt;</code> tags for each language:</p>
  
  <pre><code>languages.each do |language|
    assert_select 'body &gt; h2', :text =&gt; language.upcase
  end
  </code></pre>
  
  <p>But this fails:</p>
  
  <pre><code>&lt;"DE"&gt; expected but was
  &lt;"SV"&gt;.
  &lt;false&gt; is not true.
  /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/assertions/selector_assertions.rb:299:in `assert_select'
      ~/foo/test/functional/api/keywords_controller_test.rb:123:in `test_html'
  </code></pre>
  
  <p>I know that I can use <code>assert_match %q{&lt;h2&gt;#{language.upcase}&lt;/h2&gt;}</code> in my block, but that feels so crufty when <code>assert_select</code> exists.</p>
  
  <p>Any ideas?</p>