Minecraft wiki entry for Development_versions, associated text: Naming a sheep "jeb_" (with a name tag) will make the sheep wool fade between the different dye colors in order (like a rainbow effect).
Shearing produces the color wool the sheep had before it was named.