Scalar-tensor gravity in an accelerating universe