 <p>I just came across this question looking to check if a specific Rails route was already present:</p> <pre><code>route = "mount Blorgh::Engine" File.open('config/routes.rb').each_line.any? {|line| line[/#{route}/] } </code></pre>