title: Why a get "groovy.lang.MissingMethodException: No signature of method" when call with-method in spock?
body: <p>I have an integration test. Some code from it:</p>
  
  <pre><code>Test1 {
          static closure1 = { Class1 resultState, Class1 originState -&gt;
              with(resultState) {
                  name == originState.name
                  breed == originState.breed
                  bornDate == originState.bornDate
              }
          }
  
          @Unroll
          def 'exercise #methodName'() {
              ...
              expected(resultState, originState)
              ...
              methodName  || expected
              'name1'     || closure1
          }
  }
  </code></pre>
  
  <p>I get an groovy.lang.MissingMethodException: No signature of method: Test1$__clinit__closure10.with() is applicable for argument types: (Class1, Test1$__clinit__closure10$_closure12) values: [//values].</p>
  
  <p>But when I refactor my code to form with method instead of closure, everything is fine.</p>
  
  <pre><code>    Test1 {
  
              void method1(Class1 resultState, Class1 originState) {
                  with(resultState) {
                      name == originState.name
                      breed == originState.breed
                      bornDate == originState.bornDate
                  }
              }
  
              @Unroll
              def 'exercise #methodName'() {
                  ...
                  expected(resultState, originState)
                  ...
                  methodName  || expected
                  'name1'     || closure1
               }
  
  
          }
  </code></pre>
  
  <p>But why?? In closure-from I'm getting the exception in with-block, not in closure call.
  In my other test form of test with closures (but without with-block) works fine. Type of closure here - Closure, in other test - Closure, if it's important.</p>
  
  <p>What's wrong in my code??</p>