Theory of radiative electron attachment to molecules: Benchmark study of CN−