title: How to check mail is sent in rspec
body: <p><strong>Actionmailer</strong></p>
  <pre><code>def welcome_send(user)
          @user = user
          mail to: user.email, subject: 'Welcome to my site', from: 'suhasmv29@gmail.com'
      end
  </code></pre>
  <p><strong>RSpec test case to verify mail has been sent</strong></p>
  <pre><code>it &quot;sends a confirmation email&quot; do
        expect { mail.to }.to change { ActionMailer::Base.deliveries.count }.by(1)
      end
  </code></pre>
  <p><strong>Error</strong></p>
  <pre><code>expected `ActionMailer::Base.deliveries.count` to have changed by 1, but was changed by 0
  
  </code></pre>