Spill the beans - means leaking out some secret.
Situation: Ram gifted a painting to Rahim on his birthday. Rahim gifted the same painting as birthday gift for Peter.
During the birthday party of Peter when Ram saw the painting, he yelled out in surprise and said the painting was gifted to Rahim by him earlier.
Rahim felt bad and asked Ram " Why did you spill the beans here? You could have asked me privately when the party is over.