title: Rspec: How to test that substring appears in string a certain amount of times?
body: <p>Trying to use the <code>.exactly</code> method but it doesn't seem to work here.</p>
  
  <pre><code>expect(data).to include(purchase.email).exactly(3).times
  </code></pre>
  
  <p>This produces the error:</p>
  
  <pre><code> NoMethodError:
     undefined method `exactly' for #&lt;RSpec::Matchers::BuiltIn::Include:0x007f85c7e71108&gt;
   # ./spec/models/csv_generator_spec.rb:34:in `block (4 levels) in &lt;top (required)&gt;'
   # ./spec/models/csv_generator_spec.rb:18:in `each'
   # ./spec/models/csv_generator_spec.rb:18:in `block (3 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>Does anyone know how I would test that a substring appears a certain amount of times in a string?</p>