The simplest way is if the gem has a config/[gem name]/routes.rb file in its directory structure. If it does, then the routes defined in that file will be merged into whatever other routes you define in your own routes.rb file in your application. When such a route has been merged into your app, you can see it when you type `rake routes` at the command prompt. It will be set off from the other routes, usually by a namespace.
Note that Rails uses the "first match wins" strategy here, so if you want to override a route that will be claimed later by a gem (gem routes load after the application's own routes) then if your app defines the same route, whatever you have defined in your routes file will own that route, and the route defined in the gem will be ignored.
I believe there are other ways that a route can be defined programmatically, consult the Rails Guide on "Routing from the outside in" for details and links to the API documentation.