From 218dc5b6f905d6e6ce07e338f0625af0219c8255 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Tue, 19 Nov 2024 11:28:36 -0800 Subject: [PATCH] Improve Solargraph LSP in our spec files The main thing is that I was getting "RequireNotFound" warnings for `require 'rails_helper'`, because the LSP seems unaware of how RSpec offers `spec/` as a root for requires. I think the `require_relative` is clearer anyway, I'm decently satisfied with it. And if I decide it's too much ugly, we can try something else in the Solargraph config or something sometime! --- .gitignore | 1 + Gemfile | 6 ++++-- spec/models/color_spec.rb | 2 +- spec/models/pet_spec.rb | 2 +- spec/models/pet_type_spec.rb | 2 +- spec/models/species_spec.rb | 2 +- spec/services/nc_mall_spec.rb | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 9efbf585..9fc689de 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ tmp/**/* .env .env.* /spec/examples.txt +/.yardoc /app/assets/builds/* !/app/assets/builds/.keep diff --git a/Gemfile b/Gemfile index ab0ef624..c9ba1d48 100644 --- a/Gemfile +++ b/Gemfile @@ -84,8 +84,10 @@ gem "sentry-rails", "~> 5.12" gem "shell", "~> 0.8.1" # For workspace autocomplete. -gem "solargraph", "~> 0.50.0", group: :development -gem "solargraph-rails", "~> 1.1", group: :development +group :development do + gem "solargraph", "~> 0.50.0" + gem "solargraph-rails", "~> 1.1" +end # For automated tests. group :development, :test do diff --git a/spec/models/color_spec.rb b/spec/models/color_spec.rb index 371bd11a..14259e03 100644 --- a/spec/models/color_spec.rb +++ b/spec/models/color_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../rails_helper' RSpec.describe Color do fixtures :colors diff --git a/spec/models/pet_spec.rb b/spec/models/pet_spec.rb index cea72c1d..aec4c280 100644 --- a/spec/models/pet_spec.rb +++ b/spec/models/pet_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../rails_helper' require_relative '../support/mocks/custom_pets' require_relative '../support/matchers/a_record_matching' diff --git a/spec/models/pet_type_spec.rb b/spec/models/pet_type_spec.rb index dbd3b3a6..906cf8a2 100644 --- a/spec/models/pet_type_spec.rb +++ b/spec/models/pet_type_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../rails_helper' RSpec.describe PetType do fixtures :colors, :species, :pet_types diff --git a/spec/models/species_spec.rb b/spec/models/species_spec.rb index 5f014357..8876de4e 100644 --- a/spec/models/species_spec.rb +++ b/spec/models/species_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../rails_helper' RSpec.describe Species do fixtures :species diff --git a/spec/services/nc_mall_spec.rb b/spec/services/nc_mall_spec.rb index 4df9315b..584c863e 100644 --- a/spec/services/nc_mall_spec.rb +++ b/spec/services/nc_mall_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' require 'webmock/rspec' +require_relative '../rails_helper' RSpec.describe Neopets::NCMall, type: :model do describe ".load_styles" do