Riding in the gym is better than nothing. But I feel that riding outside will
prepare you better. You have to deal with traffic, flats and other mechanical
issues, food and liquid management, dressing for different conditions, etc.
Stuff that you'll need to sort out.