From cf0bfa4e9e30e53e733149ba6a5052592ef96769 Mon Sep 17 00:00:00 2001 From: Andrei Lisnic Date: Wed, 2 Mar 2022 19:31:48 +0200 Subject: [PATCH] Bump deps, rename folder --- .gitignore | 6 + .solargraph.yml | 19 ++ lib/solargraph/rails/debug.rb | 10 +- solargraph-rails.gemspec | 2 +- spec/solargraph-arc/rails5_spec.rb | 151 ---------------- .../annotate_spec.rb | 0 .../autoload_spec.rb | 0 .../delegate_spec.rb | 0 .../devise_spec.rb | 0 .../model_spec.rb | 0 spec/solargraph-rails/rails5_spec.rb | 162 ++++++++++++++++++ .../rails6_spec.rb | 0 .../schema_spec.rb | 0 .../storage_spec.rb | 0 spec/spec_helper.rb | 11 +- 15 files changed, 195 insertions(+), 166 deletions(-) create mode 100644 .solargraph.yml delete mode 100644 spec/solargraph-arc/rails5_spec.rb rename spec/{solargraph-arc => solargraph-rails}/annotate_spec.rb (100%) rename spec/{solargraph-arc => solargraph-rails}/autoload_spec.rb (100%) rename spec/{solargraph-arc => solargraph-rails}/delegate_spec.rb (100%) rename spec/{solargraph-arc => solargraph-rails}/devise_spec.rb (100%) rename spec/{solargraph-arc => solargraph-rails}/model_spec.rb (100%) create mode 100644 spec/solargraph-rails/rails5_spec.rb rename spec/{solargraph-arc => solargraph-rails}/rails6_spec.rb (100%) rename spec/{solargraph-arc => solargraph-rails}/schema_spec.rb (100%) rename spec/{solargraph-arc => solargraph-rails}/storage_spec.rb (100%) diff --git a/.gitignore b/.gitignore index f9887e4..e966e49 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,12 @@ /spec/reports/ /tmp/ .DS_Store +spec/rails5/log/ +spec/rails5/tmp/ +spec/rails6/log/ +spec/rails6/tmp/ +.projections.json +.byebug_history # rspec failure tracking .rspec_status diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 0000000..8d4c086 --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,19 @@ +--- +include: +- "**/*.rb" +exclude: +- test/**/* +- vendor/**/* +- ".bundle/**/*" +require: [] +domains: [] +reporters: [] +formatter: + rubocop: + cops: safe + except: [] + only: [] + extra_args: [] +require_paths: [] +plugins: [] +max_files: 5000 diff --git a/lib/solargraph/rails/debug.rb b/lib/solargraph/rails/debug.rb index 4688e3d..76abc5b 100644 --- a/lib/solargraph/rails/debug.rb +++ b/lib/solargraph/rails/debug.rb @@ -1,7 +1,7 @@ module Solargraph module Rails class Debug - def self.run(query=nil) + def self.run(query = nil) self.new.run(query) end @@ -18,12 +18,12 @@ def run(query) puts "Known methods for #{query}" - pin = api_map.pins.find {|p| p.path == query } + pin = api_map.pins.find { |p| p.path == query } return unless pin - api_map.get_complex_type_methods(pin.return_type).each do |pin| - puts "- #{pin.path}" - end + api_map + .get_complex_type_methods(pin.return_type) + .each { |pin| puts "- #{pin.path}" } end end end diff --git a/solargraph-rails.gemspec b/solargraph-rails.gemspec index c7bb868..99ff3e4 100644 --- a/solargraph-rails.gemspec +++ b/solargraph-rails.gemspec @@ -27,6 +27,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 12.3.3' spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_runtime_dependency 'solargraph', '>= 0.41.1' + spec.add_runtime_dependency 'solargraph', '~> 0.44.2' spec.add_runtime_dependency 'activesupport' end diff --git a/spec/solargraph-arc/rails5_spec.rb b/spec/solargraph-arc/rails5_spec.rb deleted file mode 100644 index 6fd3894..0000000 --- a/spec/solargraph-arc/rails5_spec.rb +++ /dev/null @@ -1,151 +0,0 @@ -require 'spec_helper' - -RSpec.describe "Rails 5 API" do - it "it provides Rails controller api" do - map = use_workspace "./spec/rails5" do |root| - root.write_file 'app/controllers/things_controller.rb', <<~EOS - class ThingsController < ActionController::Base - res - def index - re - end - end - EOS - end - - filename = './app/controllers/things_controller.rb' - expect(completion_at(filename, [1, 4], map)).to include("rescue_from") - - expect(completion_at(filename, [3, 5], map)) - .to include("respond_to", "redirect_to", "response", "request", "render") - end - - it "can auto-complete inside routes" do - map = use_workspace "./spec/rails5" do |root| - root.write_file 'config/routes.rb', <<~EOS - Rails.application.routes.draw do - res - resource :things do - res - end - namespace :foo do - res - end - end - EOS - end - - filename = './config/routes.rb' - expect(completion_at(filename, [1, 5], map)).to include("resources") - expect(completion_at(filename, [3, 7], map)).to include("resources") - expect(completion_at(filename, [6, 7], map)).to include("resources") - end - - it "can auto-complete inside mailers" do - map = use_workspace "./spec/rails5" do |root| - root.write_file 'app/mailers/test_mailer.rb', <<~EOS - class TestMailer < ActionMailer::Base - defa - def welcome_email - ma - end - end - EOS - end - - filename = './app/mailers/test_mailer.rb' - expect(completion_at(filename, [1, 6], map)).to include("default") - expect(completion_at(filename, [3, 6], map)).to include("mail") - end - - it "can auto-complete inside migrations" do - map = use_workspace "./spec/rails5" do |root| - root.write_file 'db/migrate/20130502114652_create_things.rb', <<~EOS - class CreateThings < ActiveRecord::Migration[5.2] - def self.up - crea - end - - def change - crea - create_table :things do |t| - t.col - end - change_table :things do |t| - t.col - end - create_join_table :things do |t| - t.col - end - end - end - EOS - end - - filename = './db/migrate/20130502114652_create_things.rb' - expect(completion_at(filename, [2, 7], map)).to include("create_table") - expect(completion_at(filename, [6, 7], map)).to include("create_table") - expect(completion_at(filename, [8, 10], map)).to include("column") - expect(completion_at(filename, [11, 10], map)).to include("column") - expect(completion_at(filename, [14, 10], map)).to include("column") - end - - it "provides completions for ActiveJob::Base", coverage: :rails5 do - map = use_workspace "./spec/rails5" - - assert_matches_definitions( - map, - "ActiveJob::Base", - "rails5/activejob", - print_stats: true - ) - end - - it "provides completions for ActionDispatch::Routing::Mapper", coverage: :rails5 do - map = use_workspace "./spec/rails5" - - assert_matches_definitions( - map, - "ActionDispatch::Routing::Mapper", - "rails5/routes", - print_stats: true - ) - end - - it "provides completions for ActiveRecord::Base", coverage: :rails5 do - map = use_workspace "./spec/rails5" - - assert_matches_definitions( - map, - "ActiveRecord::Base", - "rails5/activerecord", - print_stats: true - ) - end - - it "provides completions for ActionController::Base", coverage: :rails5 do - map = use_workspace "./spec/rails5" - assert_matches_definitions( - map, - "ActionController::Base", - "rails5/actioncontroller", - print_stats: true - ) - end - - it "auto-completes ActiveSupport core extensions", coverage: :rails5 do - map = use_workspace "./spec/rails5" - - Dir.glob("spec/definitions/rails5/core/*.yml").each do |path| - name = File.basename(path).split(".").first - - assert_matches_definitions( - map, - name, - "rails5/core/#{name}", - print_stats: true - ) - end - end -end - diff --git a/spec/solargraph-arc/annotate_spec.rb b/spec/solargraph-rails/annotate_spec.rb similarity index 100% rename from spec/solargraph-arc/annotate_spec.rb rename to spec/solargraph-rails/annotate_spec.rb diff --git a/spec/solargraph-arc/autoload_spec.rb b/spec/solargraph-rails/autoload_spec.rb similarity index 100% rename from spec/solargraph-arc/autoload_spec.rb rename to spec/solargraph-rails/autoload_spec.rb diff --git a/spec/solargraph-arc/delegate_spec.rb b/spec/solargraph-rails/delegate_spec.rb similarity index 100% rename from spec/solargraph-arc/delegate_spec.rb rename to spec/solargraph-rails/delegate_spec.rb diff --git a/spec/solargraph-arc/devise_spec.rb b/spec/solargraph-rails/devise_spec.rb similarity index 100% rename from spec/solargraph-arc/devise_spec.rb rename to spec/solargraph-rails/devise_spec.rb diff --git a/spec/solargraph-arc/model_spec.rb b/spec/solargraph-rails/model_spec.rb similarity index 100% rename from spec/solargraph-arc/model_spec.rb rename to spec/solargraph-rails/model_spec.rb diff --git a/spec/solargraph-rails/rails5_spec.rb b/spec/solargraph-rails/rails5_spec.rb new file mode 100644 index 0000000..bf1070e --- /dev/null +++ b/spec/solargraph-rails/rails5_spec.rb @@ -0,0 +1,162 @@ +require 'spec_helper' + +RSpec.describe 'Rails 5 API' do + it 'it provides Rails controller api' do + map = + use_workspace './spec/rails5' do |root| + root.write_file 'app/controllers/things_controller.rb', <<~EOS + class ThingsController < ActionController::Base + res + def index + re + end + end + EOS + end + + filename = './app/controllers/things_controller.rb' + expect(completion_at(filename, [1, 4], map)).to include('rescue_from') + + expect(completion_at(filename, [3, 5], map)).to include( + 'respond_to', + 'redirect_to', + 'response', + 'request', + 'render' + ) + end + + it 'can auto-complete inside routes' do + map = + use_workspace './spec/rails5' do |root| + root.write_file 'config/routes.rb', <<~EOS + Rails.application.routes.draw do + res + resource :things do + res + end + namespace :foo do + res + end + end + EOS + end + + filename = './config/routes.rb' + expect(completion_at(filename, [1, 5], map)).to include('resources') + expect(completion_at(filename, [3, 7], map)).to include('resources') + expect(completion_at(filename, [6, 7], map)).to include('resources') + end + + it 'can auto-complete inside mailers' do + map = + use_workspace './spec/rails5' do |root| + root.write_file 'app/mailers/test_mailer.rb', <<~EOS + class TestMailer < ActionMailer::Base + defa + def welcome_email + ma + end + end + EOS + end + + filename = './app/mailers/test_mailer.rb' + expect(completion_at(filename, [1, 6], map)).to include('default') + expect(completion_at(filename, [3, 6], map)).to include('mail') + end + + it 'can auto-complete inside migrations' do + map = + use_workspace './spec/rails5' do |root| + root.write_file 'db/migrate/20130502114652_create_things.rb', <<~EOS + class CreateThings < ActiveRecord::Migration[5.2] + def self.up + crea + end + + def change + crea + create_table :things do |t| + t.col + end + change_table :things do |t| + t.col + end + create_join_table :things do |t| + t.col + end + end + end + EOS + end + + filename = './db/migrate/20130502114652_create_things.rb' + expect(completion_at(filename, [2, 7], map)).to include('create_table') + expect(completion_at(filename, [6, 7], map)).to include('create_table') + expect(completion_at(filename, [8, 10], map)).to include('column') + expect(completion_at(filename, [11, 10], map)).to include('column') + expect(completion_at(filename, [14, 10], map)).to include('column') + end + + it 'provides completions for ActiveJob::Base', coverage: :rails5 do + map = use_workspace './spec/rails5' + + assert_matches_definitions( + map, + 'ActiveJob::Base', + 'rails5/activejob', + print_stats: true + ) + end + + it 'provides completions for ActionDispatch::Routing::Mapper', + coverage: :rails5 do + map = use_workspace './spec/rails5' + + assert_matches_definitions( + map, + 'ActionDispatch::Routing::Mapper', + 'rails5/routes', + print_stats: true + ) + end + + it 'provides completions for ActiveRecord::Base', coverage: :rails5 do + map = use_workspace './spec/rails5' + + assert_matches_definitions( + map, + 'ActiveRecord::Base', + 'rails5/activerecord', + print_stats: true + ) + end + + it 'provides completions for ActionController::Base', coverage: :rails5 do + map = use_workspace './spec/rails5' + assert_matches_definitions( + map, + 'ActionController::Base', + 'rails5/actioncontroller', + print_stats: true + ) + end + + it 'auto-completes ActiveSupport core extensions', coverage: :rails5 do + map = use_workspace './spec/rails5' + + Dir + .glob('spec/definitions/rails5/core/*.yml') + .each do |path| + name = File.basename(path).split('.').first + + assert_matches_definitions( + map, + name, + "rails5/core/#{name}", + print_stats: true + ) + end + end +end diff --git a/spec/solargraph-arc/rails6_spec.rb b/spec/solargraph-rails/rails6_spec.rb similarity index 100% rename from spec/solargraph-arc/rails6_spec.rb rename to spec/solargraph-rails/rails6_spec.rb diff --git a/spec/solargraph-arc/schema_spec.rb b/spec/solargraph-rails/schema_spec.rb similarity index 100% rename from spec/solargraph-arc/schema_spec.rb rename to spec/solargraph-rails/schema_spec.rb diff --git a/spec/solargraph-arc/storage_spec.rb b/spec/solargraph-rails/storage_spec.rb similarity index 100% rename from spec/solargraph-arc/storage_spec.rb rename to spec/solargraph-rails/storage_spec.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ffd6c44..fe0a601 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,6 +2,8 @@ require 'solargraph' require 'solargraph-rails' +require 'logger' +require 'byebug' require_relative './helpers' RSpec.configure do |config| @@ -43,15 +45,6 @@ Solargraph.logger.level = Logger::INFO end - config.after(:suite) do - if coverages.any? - coverages.each do |key, data| - sorted = data.sort_by { |hash| hash[:class_name] } - File.write("coverage/#{key}.json", JSON.pretty_generate(sorted)) - end - end - end - config.default_formatter = 'doc' if config.files_to_run.one? config.order = :random