/**
* Assert a model attribute value with the given Hamcrest {@link Matcher}.
*/
public <T> ResultMatcher attribute(final String name, final Matcher<T> matcher) {
return new ResultMatcher() {
@Override
@SuppressWarnings("unchecked")
public void match(MvcResult result) throws Exception {
ModelAndView mav = getModelAndView(result);
assertThat("Model attribute '" + name + "'", (T) mav.getModel().get(name), matcher);