The thing to keep in mind is that most components on a bike can be easily and inexpensively replaced. Bad rear derailleur? Big dealyou get a new Shimano Ultegra derailleur for $50, maybe a new chain for $20, and you're golden. Two exceptions to this rule: Frame and wheels. So check the frame very carefully for cracks. Really look it over, particularly at the joints around the headset and the seatpost. These are high-stress areas. Look for alignment problems or extensive re-painting that may indicate a major prang. Take the seat post out, and check for corrosion if it's a steel bike. If aluminum, keep in mind the material is very thin, so dents or scrapes may have an impact. But, a few minor nicks shouldn't cause any problem.
On the wheels, spin them and look straight down to see if they're running true. Look at the spots where the spokes meet the rimcracks indicate problems. And see if the brake pads have cut big grooves in the sidewall.
Other than that, check the fit. A bike that's a bit small can perhaps be fixed with a different stem, but a bike that's too big is no good. Then, take it home, clean it up, and make it yours!