Integrate rubocop

This is #78 rebased against master, squashed and taken a bit further.

I've also extracted a base rspec file as suggested by @JonRowe in #78; once it's reviewed by someone else I plan to move it into rspec-dev as part of the normal way we distribute shared build files.