title: Get full text content of html email in RSpec
body: <p>How do i get the full text content of an html email as single line string in rspec?</p>
  
  <p>Let's say this is the mail.html.haml:</p>
  
  <pre><code>%p 
    This product is worth: 
    = @amount
    So buy it now!
  </code></pre>
  
  <p>In rspec i send the email first and then do this:</p>
  
  <pre><code>expect(ActionMailer::Base.deliveries.last.html_part.body).to include("This product is worth: €30 So buy it now")
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>expect(ActionMailer::Base.deliveries.last.html_part.body.raw_source).to include("This product is worth: €30 So buy it now")
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>expect(ActionMailer::Base.deliveries.last.html_part.body.raw_source).to have_content("This product is worth: €30 So buy it now")
  </code></pre>
  
  <p>These doesnt work because the html outputs to rspec like this:</p>
  
  <pre><code> + This product is worth:
   + €30
   + So buy it now!
  </code></pre>
  
  <p>So my original code is right but i cant seem to grab it in rspec. How do i combine these 3 lines to 1 single line so i can call include or have_content on it correctly?</p>
  
  <p><strong>*EDIT</strong></p>
  
  <pre><code>Failure/Error:
         expect(ActionMailer::Base.deliveries.last.html_part.body.raw_source).to have_content(%q|This product is worth:
                                                                                                 €30
                                                                                                 So buy it now!|)
  
         expected        
         &lt;p&gt;
         This product is worth:
         €30
         So buy it now!
         Good luck!
         &lt;/p&gt;
  </code></pre>