Cosmological distances with general-relativistic ray tracing: framework and comparison to cosmographic predictions