Improve Rails app detection
Motivation
Closes https://github.com/Shopify/ruby-lsp/issues/1466
Implementation
Check for the presence of bin/rails as suggested by Rafael.
Automated Tests
Included
Manual Tests
It's slightly awkward as we need to ensure the setup process doesn't end up installing the published version:
- Check out this branch.
- Temporarily change the version to something nonsense value, e.g.
0.14.999so you can easily identify it. - Run
gem build - Run
gem install <filename> - Check out the
rails/railsrepo. - Delete the current
.ruby-lspdirectory if it exists - Reload the window
- Ensure the Ruby LSP output window doesn't show a failure for
bin/rails - Ensure
.ruby-lsp/Gemfiledoesn't containruby-lsp-rails - Remember to uninstall the temporary local gem afterwards, or it may result in confusing failures.
There is some corresponding discussion happening in https://github.com/Shopify/ruby-lsp-rails/pull/284 about what is the right approach for this.
My two cents is that, as long as the ruby-lsp-rails is not failing, we can delay this decision a little bit because we may find value in having the addon present for Ruby apps that have rails in the Gemfile, but aren't Rails applications.
Handled by https://github.com/Shopify/ruby-lsp-rails/pull/284