<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alexandra Ackerman</title>
    <description>The latest articles on DEV Community by Alexandra Ackerman (@aaackerman).</description>
    <link>https://dev.to/aaackerman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F296%2F3793148.jpeg</url>
      <title>DEV Community: Alexandra Ackerman</title>
      <link>https://dev.to/aaackerman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aaackerman"/>
    <language>en</language>
    <item>
      <title>Better ActionMailer testing with ActionMailerMatchers</title>
      <dc:creator>Alexandra Ackerman</dc:creator>
      <pubDate>Wed, 07 Sep 2016 15:59:20 +0000</pubDate>
      <link>https://dev.to/aaackerman/better-actionmailer-testing-with-actionmailermatchers</link>
      <guid>https://dev.to/aaackerman/better-actionmailer-testing-with-actionmailermatchers</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/contently/action_mailer_matchers"&gt;ActionMailerMatchers&lt;/a&gt; provides you with RSpec one-liners that help you to test sending emails in your Rails application.&lt;/p&gt;

&lt;p&gt;It is typical to test that an email has been delivered in a controller or service by doing the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expect { some_action.execute }.to change { 
  ActionMailer::Base.deliveries.count }.by(1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;However, this does not specify what email was sent and to where. &lt;a href="https://github.com/contently/action_mailer_matchers"&gt;ActionMailerMatchers&lt;/a&gt; solves this problem by providing the have_received_email matcher, which ensures that the passed email address or user (which must respond .email) was the email's “to” address. You may also use the optional subject and body arguments to check that content matches the email you were expecting to send.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expect("address@email.com").to have_received_email(body: "Wonderful email body")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expect(some_user).to have_received_email(subject: "My great subject") 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/contently/action_mailer_matchers"&gt;Check it out&lt;/a&gt; and feel free to contribute by opening an issue or pull request!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>rspec</category>
    </item>
  </channel>
</rss>
