extract boilerplate into viewSpec function