12839: Install specified version of gem if another version is already installed

Fixes #12839.

Before: If a gem is already installed, gem.installed always returns "True: Gem is already installed," even if the installed version is different than the specified version.

After: If a gem is already installed, but the installed gem is not of the specified version, gem.installed will install the specified version of the gem.