Skip to content

Commit 1fa9bd9

Browse files
committed
Add tests
1 parent 1c61c90 commit 1fa9bd9

File tree

17 files changed

+1659
-274
lines changed

17 files changed

+1659
-274
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Request a review from @Shopify/ruby-dev-exp when a new PR is created
2+
* @Shopify/ruby-dev-exp

CODE_OF_CONDUCT.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq
77+
78+

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ gem "rubocop-sorbet", "~> 0.7", require: false
1818
gem "sorbet-static-and-runtime"
1919
gem "tapioca", "~> 0.11", require: false
2020

21+
# TODO: remove this line once we release a Ruby LSP version including the hover extension point
2122
gem "ruby-lsp", path: "../ruby-lsp"

README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
# RailsRubyLsp
2-
Short description and motivation.
2+
3+
The RailsRubyLsp is a [Ruby LSP](https://github.com/Shopify/ruby-lsp) extension for extra Rails editor features. As long
4+
as this gem is a part of the project's bundle, the Ruby LSP will automatically load it to provide extra features.
35

46
## Usage
5-
How to use my plugin.
7+
8+
This gem includes two elements that together allow for more Rails functionality in the editor. The first is a Rails
9+
engine that automatically exposes some APIs when running the Rails server in development mode. The second is a Ruby LSP
10+
extension that knows how to connect to the exposed APIs to fetch runtime information from the Rails server.
11+
12+
In order to get the extra functionality in the editor, the Rails server must be running.
13+
14+
Note: the Ruby LSP does not need to be restarted every time the Rails server is booted. If you need to shutdown the
15+
server, the extra features will simply disappear and come back once the server is running again.
616

717
## Installation
18+
819
Add this line to your application's Gemfile:
920

1021
```ruby
1122
gem "rails_ruby_lsp"
1223
```
1324

14-
And then execute:
15-
```bash
16-
$ bundle
17-
```
18-
19-
Or install it yourself as:
20-
```bash
21-
$ gem install rails_ruby_lsp
22-
```
23-
2425
## Contributing
25-
Contribution directions go here.
26+
27+
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/rails_ruby_lsp. This project is
28+
intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
29+
[Contributor Covenant](https://github.com/Shopify/rails_ruby_lsp/blob/main/CODE_OF_CONDUCT.md) code of conduct.
2630

2731
## License
28-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
32+
33+
The gem is available as open source under the terms of the
34+
[MIT License](https://github.com/Shopify/rails_ruby_lsp/blob/main/LICENSE.txt).

Rakefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
require "bundler/setup"
44

55
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
6-
load "rails/tasks/engine.rake"
76

7+
load "rails/tasks/engine.rake"
88
load "rails/tasks/statistics.rake"
99

1010
require "bundler/gem_tasks"
11+
require "rake/testtask"
12+
13+
Rake::TestTask.new(:test) do |t|
14+
t.libs << "test"
15+
t.libs << "lib"
16+
t.test_files = FileList["test/**/*_test.rb"]
17+
end
18+
19+
task default: :test

lib/rails_ruby_lsp.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
require "rails_ruby_lsp/engine"
66

77
module RailsRubyLsp
8-
# Your code goes here...
98
end

lib/rails_ruby_lsp/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Engine < ::Rails::Engine
1010

1111
initializer "rails_ruby_lsp.routes" do
1212
config.after_initialize do |app|
13-
if Rails.env.development?
13+
if Rails.env.development? || Rails.env.test?
1414
app.routes.prepend do
1515
T.bind(self, ActionDispatch::Routing::Mapper)
1616
mount(RailsRubyLsp::Engine => "/rails_ruby_lsp")

lib/ruby_lsp/hover.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run(target)
1616
schema_file = File.join(RailsClient.instance.root, "db", "schema.rb")
1717
content = +""
1818
content << "[Schema](file://#{schema_file})\n\n" if File.exist?(schema_file)
19-
content << model[:columns].map { |name, type| "**#{name}** | #{type}\n" }.join("\n")
19+
content << model[:columns].map { |name, type| "**#{name}**: #{type}\n" }.join("\n")
2020
content
2121
end
2222
end

sorbet/rbi/dsl/rails_ruby_lsp/models_controller.rbi

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)