Skip to content

Instantly share code, notes, and snippets.

@finneycanhelp
Created January 17, 2011 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finneycanhelp/783407 to your computer and use it in GitHub Desktop.
Save finneycanhelp/783407 to your computer and use it in GitHub Desktop.
Test Showing Why "as" operator is important
package com
import grails.test.GrailsUnitTestCase;
import com.SomeService
class SomethingTests extends GrailsUnitTestCase {
void testSomething() {
Something thing = new Something()
// thing.someService = [ get : { a -> throw new Throwable() } ] as SomeService // works
thing.someService = [ get : { a -> throw new Throwable() } ] // need the "as" operator!
assert thing.methodWeAreTesting()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment