Fixes bug 10628.

Railties tests non-existent Rake::Application in some cases. Fixed in this pull request.