It looks green, it opens red. What you eat is red, but what you spit out is black. What is it?

A watermelon!