How to color vertices of cube
It seems like your UV mapping is off; using a similar setup and a default cube, I'm getting this result:



You can also achieve what you're trying to do using vertex colors:



Also see: How can vertex paint be rendered?