title: Grails / Spock: How to mock single method within class where method is called from within the class itself?
body: <p>Given the following, how do I mock processMessage() using Spock, so that I can check that processBulkMessage() calls processMessage() n times, where n is the number of messages within a BulkMessage?</p>
  
  <pre><code>class BulkMessage {
      List messages
  }
  
  class MyService {
  
      def processBulkMessage(BulkMessage msg) {
          msg.messages.each {subMsg-&gt;
              processMessage(subMsg)
          }
      }
  
      def processMessage(Message message) {
  
      }
  }
  </code></pre>