Skip to content

Instantly share code, notes, and snippets.

@Teqqles
Created January 22, 2013 07:57
Show Gist options
  • Save Teqqles/4592889 to your computer and use it in GitHub Desktop.
Save Teqqles/4592889 to your computer and use it in GitHub Desktop.
Creating and asserting a mocked interface with MockFor
def expected = "text/plain";
mock = new MockFor( HttpServletResponse.class );
mock.demand.with {
setContentType{ String got -> assert expected == got }
}
def mockHttpServletResponse = mock.proxyInstance();
def themeWriter = new ThemeWriter( mockHttpServletResponse );
themeWriter.generateResponse();
mock.verify( mockHttpServletResponse );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment