The Jenius by Dick King-Smith
Judy is eight and believes that Guinea-pigs are highly intelligent and can be taught to obey commands. She trains her new guinea pig, Jenius. to 'walk on a lead', 'speak' and even, 'die for his country'. It was all arranged, all the children were bringing their pets into school so that Judy could prove just how clever Jenius was. But Jenius is put next to a cat and is so frightened that he 'dies for his country' and doesn't move. Everyone laughs at Judy but she gets the last laugh when her dad has to eat his hat when Jenius performs at home.