title: how to integration test email body in a Grails Service that uses the Mail plugin
body: <p>I am attempting to write integration tests for a Grails service that does, among other things, send email via the excellent <a href="http://grails.org/plugin/mail" rel="nofollow">Mail Plugin</a>.  I can disable the actual sending of email via configuration, which is great, but I would like to verify that the parameters are correct body is being rendered correctly, or at very least that the method has been called when I expect.  As per the documentation, the full path to GSP for the body must be supplied.</p>
  
  <p>As part my test I'd like to do something like this - is there a way to access the email body and other parameters programmatically after sending?</p>
  
  <pre><code>sendMail {
    to myemailparams.to
    subject myemailparams.subject
    body( view:"/emailviews/someemailview", 
        model:[contentparam: myemailparams.somecontentvalue)
  }
  
  //verify correct sending to and subject parameters, and that body contains correct contentvalue
  //or at least that the method has been called (Mock it out?)
  </code></pre>
  
  <p>Note I realize that I can encapsulate the testing of the email body rendering into a separate isolated test that doesn't involve the mail plugin.  But the purpose of this integration test is to ensure a lot of things, including the email send, happen correctly upon call to the service method.  I would even be satisfied with an answer that describes how to mock the service, and a check that verifies 'sendMail' has been called when expected.</p>