Skip to content

Commit

Permalink
Only require parts of Rails actually needed
Browse files Browse the repository at this point in the history
In our app we don't need Action Cable/Text/Mailbox etc and we don't want to pull it in for this gem.
  • Loading branch information
bdewater committed Nov 8, 2023
1 parent b83f10a commit 946348f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 61 deletions.
31 changes: 16 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ PATH
remote: .
specs:
ruby-lsp-rails (0.2.7)
rails (>= 6.0)
actionpack (>= 6.0)
activerecord (>= 6.0)
railties (>= 6.0)
ruby-lsp (>= 0.12.0, < 0.13.0)
sorbet-runtime (>= 0.5.9897)

Expand All @@ -117,16 +119,16 @@ GEM
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.3)
debug (1.8.0)
date (3.3.4)
debug (1.7.2)
irb (>= 1.5.0)
reline (>= 0.3.1)
drb (2.1.1)
ruby2_keywords
erubi (1.12.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
io-console (0.6.0)
irb (1.8.3)
Expand All @@ -136,7 +138,7 @@ GEM
language_server-protocol (3.17.0.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
nokogiri (>= 1.5.9)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
Expand All @@ -145,15 +147,15 @@ GEM
marcel (1.0.2)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
mocha (2.1.0)
minitest (5.18.0)
mocha (2.0.2)
ruby2_keywords (>= 0.0.5)
net-imap (0.4.3)
net-imap (0.4.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-protocol
Expand Down Expand Up @@ -190,9 +192,9 @@ GEM
nokogiri (~> 1.14)
rainbow (3.1.1)
rake (13.1.0)
rbi (0.1.1)
rbi (0.1.4)
prism (>= 0.17.1, < 0.18)
sorbet-runtime (>= 0.5.9204)
yarp (>= 0.11.0)
rdoc (6.6.0)
psych (>= 4.0.0)
regexp_parser (2.8.2)
Expand Down Expand Up @@ -240,7 +242,7 @@ GEM
sorbet-static-and-runtime (>= 0.5.10187)
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
sqlite3 (1.6.7)
sqlite3 (1.6.8)
mini_portile2 (~> 2.8.0)
stringio (3.0.8)
syntax_tree (6.2.0)
Expand All @@ -255,12 +257,12 @@ GEM
thor (>= 1.2.0)
yard-sorbet
thor (1.3.0)
timeout (0.4.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.3)
tzinfo (>= 1.0.0)
unicode-display_width (2.5.0)
unicode-display_width (2.4.2)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
Expand All @@ -269,7 +271,6 @@ GEM
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
yarp (0.12.0)
zeitwerk (2.6.12)

PLATFORMS
Expand Down
1 change: 0 additions & 1 deletion bin/rails
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/engine/commands"
4 changes: 3 additions & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
Dir["{app,config,db,lib}/**/*", "LICENSE.txt", "Rakefile", "README.md"]
end

spec.add_dependency("rails", ">= 6.0")
spec.add_dependency("actionpack", ">= 6.0")
spec.add_dependency("activerecord", ">= 6.0")
spec.add_dependency("railties", ">= 6.0")
spec.add_dependency("ruby-lsp", ">= 0.12.0", "< 0.13.0")
spec.add_dependency("sorbet-runtime", ">= 0.5.9897")
end
7 changes: 0 additions & 7 deletions test/dummy/app/channels/application_cable/channel.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/dummy/app/channels/application_cable/connection.rb

This file was deleted.

10 changes: 0 additions & 10 deletions test/dummy/app/jobs/application_job.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/dummy/app/mailers/application_mailer.rb

This file was deleted.

12 changes: 11 additions & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

require_relative "boot"

require "rails/all"
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
12 changes: 1 addition & 11 deletions test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?
config.eager_load = true

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
Expand All @@ -36,16 +36,6 @@
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false

# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test

config.action_mailer.perform_caching = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

Expand Down
2 changes: 1 addition & 1 deletion test/ruby_lsp_rails/rack_app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RackAppTest < ActionDispatch::IntegrationTest
end

test "GET show returns not_found if class is not a model" do
get "/ruby_lsp_rails/models/ApplicationJob"
get "/ruby_lsp_rails/models/Time"
assert_response(:not_found)
end

Expand Down

0 comments on commit 946348f

Please sign in to comment.