title: Spock: using a Mock inside a "where" clause table?
body: <p>I am trying to use ia mocked object in the table of a "where" clause. Basically something like this:</p>
  
  <pre><code>def "my test"(){
  
      given:
      InjectedObject1 inj1 = Mock()
      InjectedObject2 inj2 = Mock()
      SystemUnderTest system = new System(inj1, inj2)
      MockedObject mocked = Mock()
  
      inj1.someMethod() &gt;&gt; list  // this will be a list of MockedObject
  
      when:
      system.execute()
  
      then:
      n * inj2.someOtherMethod()
  
      where:
      list             | n
      [mocked]         | 0
      [mocked, mocked] | 1
  }
  </code></pre>
  
  <p>This doesn't work because the "where" clause is executed before the "given" clause, so <code>mocked</code> doesn't exist yet when it is first referenced. How do I overcome this? <code>mocked</code> in used only is this test so I'd like to avoid creating it outside of this method.</p>
  
  <p>Note that this is a simplified example, there are actually more interactions, and other columns in the table that have an influence on <code>n</code> - which makes the table syntax very handy.</p>