title: How to do argument capture with spock framework?
body: <p>I have some Java stuff like this:</p>
  
  
  
  <pre class="lang-groovy prettyprint-override"><code>public interface EventBus{
      void fireEvent(GwtEvent&lt;?&gt; event);
  }
  
  
  public class SaveCommentEvent extends GwtEvent&lt;?&gt;{
      private finalComment oldComment;
      private final Comment newComment;
  
      public SaveCommentEvent(Comment oldComment,Comment newComment){
          this.oldComment=oldComment;
          this.newComment=newComment;
      }
  
      public Comment getOldComment(){...}
      public Comment getNewComment(){...}
  }
  </code></pre>
  
  <p>and test code like this:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>  def "...."(){
       EventBus eventBus=Mock()
       Comment oldComment=Mock()
       Comment newCommnet=Mock()
  
       when:
           eventBus.fireEvent(new SaveCommentEvent(oldComment,newComment))
  
       then:
           1*eventBus.fireEvent(
                                  {
                                     it.source.getClass()==SaveCommentEvent;
                                     it.oldComment==oldComment;
                                     it.newComment==newComment
                                   }
                                )            
  }
  </code></pre>
  
  <p>I want to verify that the <code>eventBus.fireEvent(..)</code> gets called once with an Event with type <code>SaveCommentEvent</code> and construction parameters <code>oldComment</code> and <code>newComment</code>.</p>
  
  <p>Code runs without errors but problem is:</p>
  
  <p>After changing closure stuff from</p>
  
  <pre class="lang-groovy prettyprint-override"><code>{
     it.source.getClass()==SaveCommentEvent;
     it.oldComment==oldComment;  //old==old
     it.newComment==newComment   //new==new
  }
  </code></pre>
  
  <p>To </p>
  
  <pre class="lang-groovy prettyprint-override"><code> {
      it.source.getClass()==Other_Class_Literal;
      it.oldComment==newComment;  //old==new
      it.newComment==oldComment   //new==old
    }
  </code></pre>
  
  <p>Still, code runs without error? Apparently the closure didn't do what I want, so the question is: How to do argument capturing?</p>