In 2268, she was tested by a species called the Vians to see if her people were worthy to be saved from a supernova that was threatening her and other planets. The Vians had the power to save only one species.
Spock, McCoy, and Kirk were kidnapped by the Vians and subjected to various forms of torture to test Gem's reaction and to determine if her species was worthy of being saved. They wanted to know if Gem would help them. The Vians wanted to be certain that she and her people could learn the principles of self-sacrifice, compassion and the love of life from her contact with the Humans. These qualities would make her civilization worthy to survive.
The Vians tested Gem's capacity for compassion and how far she would go to save another being. After Kirk was tortured, Gem healed his wounds. When Dr. McCoy was tortured and near death, Gem was at first frightened by the extent of his injuries and did not help him. Then, Gem approached McCoy and moved her hands on McCoy's face, transferring his injuries to herself. Gem then collapsed, sobbing, and recoiled in fear because she knew that to heal him, she would have to die. She tried to help him more, but moved away in fear.
However, she overcame her fears and offered her life to save McCoy's, but McCoy refused to allow her to die and shoved her away. The Vians healed McCoy after Kirk convinced them that Gem offering her life was sufficiently compassionate and actually going through with it was not necessary.