title: How to mock String.equals in Groovy?
body: <p>For testing purpose i need to override 'equals' method:</p>
  
  <pre><code>def any = [equals: { true }] as String
  any == 'should be true'
  // false
  </code></pre>
  
  <p>More detailed about problem:</p>
  
  <pre><code>class EmployeeEndpointSpec extends RestSpecification {
  
      void "test employee" () {
          when:
              get "/v1/employee", parameters
          then:
              expectedStatus.equals(response.statusCode)
              expectedJson.equals(response.json)
          where:
              parameters  &lt;&lt; [
                  [:],
                  [id: 824633720833, style: "small"]
              ]
              expectedStatus &lt;&lt; [
                  HttpStatus.BAD_REQUEST,
                  HttpStatus.OK
              ]
              expectedJson &lt;&lt; [
                  [errorCode: "badRequest"],
                  [
                      id: 824633720833,
                      name: "Jimmy",
                      email: "jimmy@fakemail.com",
                      dateCreated:"2015-01-01T01:01:00.000", // this value should be ignored
                      lastUpdated: "2015-01-01T01:01:00.000" // and this
                  ]
              ]
      }
  }
  </code></pre>
  
  <p><code>lastUpdated</code> and <code>dateCreated</code> may change in time, and i need 
  somehow ignore them.</p>