Skip to content

Commit

Permalink
Bump deps, rename folder
Browse files Browse the repository at this point in the history
  • Loading branch information
alisnic committed Mar 2, 2022
1 parent 2cfd819 commit cf0bfa4
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 166 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions .solargraph.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions lib/solargraph/rails/debug.rb
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion solargraph-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
151 changes: 0 additions & 151 deletions spec/solargraph-arc/rails5_spec.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
162 changes: 162 additions & 0 deletions spec/solargraph-rails/rails5_spec.rb
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cf0bfa4

Please sign in to comment.