When our codebase was still in Grails 2.1.4, this unit test for our interceptors worked with full coverage:
@Before
void setUp() {
gmc = new GMockController()
apiProducts = gmc.mock()
api.products.returns(apiProducts).stub()
controller.api = api
}
void testBeforeInterceptor() {
// Arrange
setUp()
def ctrl = gmc.mock(controller)
params.id = 1
ctrl.actionName.returns('view')
apiProducts.get(params.id)
// Act
gmc.play {
controller.beforeInterceptor()
}
}
After switching to Grails 2.2.2, it seems like this doesn't cover the test like it used to in 2.1.4. The error "Unexpected method call" is being called out since it won't go through the interceptors like it used to in 2.1.4.
Was there a change in how interceptors are tested?
I've searched around and it seems like no one has the answer for this. The documentation on testing interceptors are sparse. Any ideas?