solargraph-rspec 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +2 -2
- data/CHANGELOG.md +29 -0
- data/README.md +9 -12
- data/gemfiles/default.gemfile +2 -2
- data/gemfiles/default.gemfile.lock +52 -29
- data/lib/solargraph/rspec/config.rb +20 -0
- data/lib/solargraph/rspec/convention.rb +10 -1
- data/lib/solargraph/rspec/correctors/base.rb +19 -3
- data/lib/solargraph/rspec/rspec_configure.rb +67 -0
- data/lib/solargraph/rspec/spec_configuration_walker.rb +74 -0
- data/lib/solargraph/rspec/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5479aea692e6eb35870d21e537641872b30e6bdfe8a868110d79488f84c4964
|
|
4
|
+
data.tar.gz: 4c8bfb43f8dececdfe0d19b9c50a963e487caa0c623a020c67f82f0a83f55b7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c098385b10b165f9619f0e64a0ad01b5da028fcd9e0f90a028f48132438d29af1394967492d2de9a964d66da98bcd6a8a66207af7d8903a853aca6ad3e52d86f
|
|
7
|
+
data.tar.gz: cf40aae6cb2777d1314bf6c510e4f38c2227f43b2bde6db5b3ed4144358775151c17f4a95970da9d0a9fcb295b0305b6226c11472e25e5ec6cf49e8e56fd772c
|
data/Appraisals
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
appraise 'default' do
|
|
4
4
|
# default gems from Gemfile
|
|
5
5
|
gem 'net-imap', '~> 0.4.0' # https://github.com/lsegal/yard/issues/1629
|
|
6
|
-
gem 'actionmailer'
|
|
6
|
+
gem 'actionmailer', '>= 7'
|
|
7
7
|
gem 'airborne'
|
|
8
|
-
gem 'rspec-rails'
|
|
8
|
+
gem 'rspec-rails', '>= 7'
|
|
9
9
|
gem 'rspec-sidekiq'
|
|
10
10
|
gem 'shoulda-matchers'
|
|
11
11
|
gem 'webmock'
|
data/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-08-12
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Add Rspec included modules support by @ShadiestGoat in #32
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Chore: Test solargraph prereleases (#31)
|
|
17
|
+
- Chore: More reliable closure and location updates by @apiology in #30
|
|
18
|
+
- Chore: Less limiting of gem pin processing in specs by @apiology in #29
|
|
19
|
+
Avoid inference from literal values by @castwide (#34)
|
|
20
|
+
- Chore: fix failing specs (#35)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [0.5.5] - 2025-10-05
|
|
24
|
+
|
|
10
25
|
### Fixed
|
|
11
26
|
- Go-to-defintion/Hover for RSpec DSL methods (eg. context or it)
|
|
12
27
|
|
|
28
|
+
### Other Changes
|
|
29
|
+
- Chore: Add rubocop-yard by @lekemula in #20
|
|
30
|
+
- Chore: Add CI solargraph typecheck step by @lekemula in #21
|
|
31
|
+
- Chore: Adjust specs/CI for next solargraph release after 0.56.2 by @lekemula in #22
|
|
32
|
+
- Chore: Improve CI speed by @lekemula in #23
|
|
33
|
+
- Chore: Improve tests speed by @lekemula in #24
|
|
34
|
+
- Chore: Update testing steps in developer documentation by @apiology in #25
|
|
35
|
+
- Chore: Move 3rd party gems to Appraisals by @lekemula in #27
|
|
36
|
+
|
|
13
37
|
### Changed
|
|
14
38
|
- Update testing steps in developer documentation
|
|
15
39
|
|
|
40
|
+
## [0.5.4] - 2025-09-06
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- Fix breaking of solargraph rubocop diagnostics by @lekemula in #19
|
|
44
|
+
|
|
16
45
|
## [0.5.3] - 2025-09-02
|
|
17
46
|
|
|
18
47
|
### Fixed
|
data/README.md
CHANGED
|
@@ -77,27 +77,25 @@ Add `solargraph-rspec` to your `.solargraph.yml` as a plugin.
|
|
|
77
77
|
```
|
|
78
78
|
### Configuration
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
You can customize the plugin behavior in your `.solargraph.yml`:
|
|
81
81
|
|
|
82
82
|
```yaml
|
|
83
83
|
# .solargraph.yml
|
|
84
84
|
# ...
|
|
85
85
|
rspec:
|
|
86
|
+
# Custom let-like memoized methods (e.g., from rspec-given, test-prof)
|
|
86
87
|
let_methods:
|
|
87
88
|
- let_it_be
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
If you have your own custom `example`-like methods like `it`, you can add them to your `.solargraph.yml` file like this:
|
|
91
89
|
|
|
92
|
-
|
|
93
|
-
# .solargraph.yml
|
|
94
|
-
# ...
|
|
95
|
-
rspec:
|
|
90
|
+
# Custom example-like methods (e.g., from rspec-given)
|
|
96
91
|
example_methods:
|
|
97
92
|
- my_it
|
|
98
|
-
```
|
|
99
93
|
|
|
100
|
-
|
|
94
|
+
# RSpec helper files to analyze for included modules (shared contexts, custom matchers)
|
|
95
|
+
config_helper_files:
|
|
96
|
+
- spec/spec_helper.rb
|
|
97
|
+
- spec/rails_helper.rb
|
|
98
|
+
```
|
|
101
99
|
|
|
102
100
|
|
|
103
101
|
### Gem completions
|
|
@@ -136,8 +134,7 @@ Contributing is easy - note that this Gem uses 'appraisal' to test against RSpec
|
|
|
136
134
|
bundle exec appraisal install
|
|
137
135
|
cp .solargraph.yml.example .solargraph.yml
|
|
138
136
|
bundle exec appraisal bundle exec rbs collection update
|
|
139
|
-
|
|
140
|
-
bundle exec appraisal bundle exec solargraph gems $rspec_gems
|
|
137
|
+
bundle exec appraisal bundle exec solargraph gems $(bundle exec appraisal bundle exec ruby -r './lib/solargraph-rspec' -e 'puts Solargraph::Rspec::Gems.gem_names.join(" ")' 2>/dev/null | tail -n1)
|
|
141
138
|
bundle exec appraisal rspec
|
|
142
139
|
```
|
|
143
140
|
3. Introduce your awesome changes
|
data/gemfiles/default.gemfile
CHANGED
|
@@ -16,9 +16,9 @@ gem "simplecov"
|
|
|
16
16
|
gem "simplecov-cobertura"
|
|
17
17
|
gem "unparser"
|
|
18
18
|
gem "net-imap", "~> 0.4.0"
|
|
19
|
-
gem "actionmailer"
|
|
19
|
+
gem "actionmailer", ">= 7"
|
|
20
20
|
gem "airborne"
|
|
21
|
-
gem "rspec-rails"
|
|
21
|
+
gem "rspec-rails", ">= 7"
|
|
22
22
|
gem "rspec-sidekiq"
|
|
23
23
|
gem "shoulda-matchers"
|
|
24
24
|
gem "webmock"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
solargraph-rspec (0.5.
|
|
4
|
+
solargraph-rspec (0.5.5)
|
|
5
5
|
solargraph (>= 0.52.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -61,11 +61,13 @@ GEM
|
|
|
61
61
|
ast (2.4.3)
|
|
62
62
|
backport (1.2.0)
|
|
63
63
|
base64 (0.3.0)
|
|
64
|
-
benchmark (0.
|
|
64
|
+
benchmark (0.5.0)
|
|
65
65
|
bigdecimal (3.2.3)
|
|
66
66
|
builder (3.3.0)
|
|
67
67
|
byebug (12.0.0)
|
|
68
68
|
coderay (1.1.3)
|
|
69
|
+
commander (5.0.0)
|
|
70
|
+
highline (~> 3.0.0)
|
|
69
71
|
concurrent-ruby (1.3.5)
|
|
70
72
|
connection_pool (2.5.4)
|
|
71
73
|
crack (1.0.0)
|
|
@@ -85,6 +87,7 @@ GEM
|
|
|
85
87
|
globalid (1.2.1)
|
|
86
88
|
activesupport (>= 6.1)
|
|
87
89
|
hashdiff (1.2.1)
|
|
90
|
+
highline (3.0.1)
|
|
88
91
|
http-accept (1.7.0)
|
|
89
92
|
http-cookie (1.0.8)
|
|
90
93
|
domain_name (~> 0.5)
|
|
@@ -95,13 +98,13 @@ GEM
|
|
|
95
98
|
pp (>= 0.6.0)
|
|
96
99
|
rdoc (>= 4.0.0)
|
|
97
100
|
reline (>= 0.4.2)
|
|
98
|
-
jaro_winkler (1.
|
|
99
|
-
json (2.
|
|
100
|
-
kramdown (2.5.
|
|
101
|
-
rexml (>= 3.
|
|
101
|
+
jaro_winkler (1.7.0)
|
|
102
|
+
json (2.21.2)
|
|
103
|
+
kramdown (2.5.2)
|
|
104
|
+
rexml (>= 3.4.4)
|
|
102
105
|
kramdown-parser-gfm (1.1.0)
|
|
103
106
|
kramdown (~> 2.0)
|
|
104
|
-
language_server-protocol (3.17.0.
|
|
107
|
+
language_server-protocol (3.17.0.6)
|
|
105
108
|
lint_roller (1.1.0)
|
|
106
109
|
logger (1.7.0)
|
|
107
110
|
loofah (2.24.1)
|
|
@@ -129,20 +132,25 @@ GEM
|
|
|
129
132
|
net-smtp (0.5.1)
|
|
130
133
|
net-protocol
|
|
131
134
|
netrc (0.11.0)
|
|
132
|
-
nokogiri (1.
|
|
135
|
+
nokogiri (1.19.4-arm64-darwin)
|
|
133
136
|
racc (~> 1.4)
|
|
134
137
|
observer (0.1.2)
|
|
135
138
|
open3 (0.2.1)
|
|
136
139
|
optparse (0.6.0)
|
|
137
140
|
ostruct (0.6.3)
|
|
138
|
-
parallel (1.
|
|
139
|
-
|
|
141
|
+
parallel (2.1.0)
|
|
142
|
+
parlour (9.1.2)
|
|
143
|
+
commander (~> 5.0)
|
|
144
|
+
parser
|
|
145
|
+
rainbow (~> 3.0)
|
|
146
|
+
sorbet-runtime (>= 0.5)
|
|
147
|
+
parser (3.3.12.0)
|
|
140
148
|
ast (~> 2.4.1)
|
|
141
149
|
racc
|
|
142
150
|
pp (0.6.2)
|
|
143
151
|
prettyprint
|
|
144
152
|
prettyprint (0.2.0)
|
|
145
|
-
prism (1.
|
|
153
|
+
prism (1.9.0)
|
|
146
154
|
profile-viewer (0.0.5)
|
|
147
155
|
optparse
|
|
148
156
|
webrick
|
|
@@ -182,14 +190,17 @@ GEM
|
|
|
182
190
|
zeitwerk (~> 2.6)
|
|
183
191
|
rainbow (3.1.1)
|
|
184
192
|
rake (13.3.0)
|
|
185
|
-
rbs (
|
|
193
|
+
rbs (4.1.3)
|
|
186
194
|
logger
|
|
187
|
-
|
|
195
|
+
prism (>= 1.6.0)
|
|
196
|
+
tsort
|
|
197
|
+
rdoc (7.2.0)
|
|
188
198
|
erb
|
|
189
199
|
psych (>= 4.0.0)
|
|
200
|
+
tsort
|
|
190
201
|
redis-client (0.25.3)
|
|
191
202
|
connection_pool
|
|
192
|
-
regexp_parser (2.
|
|
203
|
+
regexp_parser (2.12.0)
|
|
193
204
|
reline (0.6.2)
|
|
194
205
|
io-console (~> 0.5)
|
|
195
206
|
rest-client (2.1.0)
|
|
@@ -197,7 +208,7 @@ GEM
|
|
|
197
208
|
http-cookie (>= 1.0.2, < 2.0)
|
|
198
209
|
mime-types (>= 1.16, < 4.0)
|
|
199
210
|
netrc (~> 0.8)
|
|
200
|
-
reverse_markdown (3.0.
|
|
211
|
+
reverse_markdown (3.0.2)
|
|
201
212
|
nokogiri
|
|
202
213
|
rexml (3.4.4)
|
|
203
214
|
rspec (3.13.1)
|
|
@@ -226,20 +237,20 @@ GEM
|
|
|
226
237
|
rspec-mocks (~> 3.0)
|
|
227
238
|
sidekiq (>= 5, < 9)
|
|
228
239
|
rspec-support (3.13.6)
|
|
229
|
-
rubocop (1.
|
|
240
|
+
rubocop (1.89.0)
|
|
230
241
|
json (~> 2.3)
|
|
231
242
|
language_server-protocol (~> 3.17.0.2)
|
|
232
243
|
lint_roller (~> 1.1.0)
|
|
233
|
-
parallel (
|
|
244
|
+
parallel (>= 1.10)
|
|
234
245
|
parser (>= 3.3.0.2)
|
|
235
246
|
rainbow (>= 2.2.2, < 4.0)
|
|
236
247
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
237
|
-
rubocop-ast (>= 1.
|
|
248
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
238
249
|
ruby-progressbar (~> 1.7)
|
|
239
250
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
240
|
-
rubocop-ast (1.
|
|
251
|
+
rubocop-ast (1.50.0)
|
|
241
252
|
parser (>= 3.3.7.2)
|
|
242
|
-
prism (~> 1.
|
|
253
|
+
prism (~> 1.7)
|
|
243
254
|
rubocop-yard (1.0.0)
|
|
244
255
|
lint_roller
|
|
245
256
|
rubocop (~> 1.72)
|
|
@@ -263,11 +274,11 @@ GEM
|
|
|
263
274
|
simplecov (~> 0.19)
|
|
264
275
|
simplecov-html (0.13.2)
|
|
265
276
|
simplecov_json_formatter (0.1.4)
|
|
266
|
-
solargraph (0.
|
|
277
|
+
solargraph (0.60.3)
|
|
267
278
|
ast (~> 2.4.3)
|
|
268
279
|
backport (~> 1.2)
|
|
269
280
|
benchmark (~> 0.4)
|
|
270
|
-
bundler (
|
|
281
|
+
bundler (>= 2.0)
|
|
271
282
|
diff-lcs (~> 1.4)
|
|
272
283
|
jaro_winkler (~> 1.6, >= 1.6.1)
|
|
273
284
|
kramdown (~> 2.3)
|
|
@@ -278,23 +289,34 @@ GEM
|
|
|
278
289
|
ostruct (~> 0.6)
|
|
279
290
|
parser (~> 3.0)
|
|
280
291
|
prism (~> 1.4)
|
|
281
|
-
rbs (>= 3.
|
|
292
|
+
rbs (>= 3.10.0)
|
|
293
|
+
rdoc (~> 7.0)
|
|
282
294
|
reverse_markdown (~> 3.0)
|
|
283
295
|
rubocop (~> 1.76)
|
|
296
|
+
sord (~> 7.0)
|
|
284
297
|
thor (~> 1.0)
|
|
285
298
|
tilt (~> 2.0)
|
|
286
299
|
yard (~> 0.9, >= 0.9.24)
|
|
287
300
|
yard-activesupport-concern (~> 0.0)
|
|
288
301
|
yard-solargraph (~> 0.1)
|
|
302
|
+
sorbet-runtime (0.6.13425)
|
|
303
|
+
sord (7.1.0)
|
|
304
|
+
commander (~> 5.0)
|
|
305
|
+
parlour (~> 9.1)
|
|
306
|
+
parser
|
|
307
|
+
rbs (>= 3.0, < 5)
|
|
308
|
+
sorbet-runtime
|
|
309
|
+
yard
|
|
289
310
|
stringio (3.1.7)
|
|
290
|
-
thor (1.
|
|
291
|
-
tilt (2.
|
|
311
|
+
thor (1.5.0)
|
|
312
|
+
tilt (2.8.0)
|
|
292
313
|
timeout (0.4.3)
|
|
314
|
+
tsort (0.2.0)
|
|
293
315
|
tzinfo (2.0.6)
|
|
294
316
|
concurrent-ruby (~> 1.0)
|
|
295
317
|
unicode-display_width (3.2.0)
|
|
296
318
|
unicode-emoji (~> 4.1)
|
|
297
|
-
unicode-emoji (4.
|
|
319
|
+
unicode-emoji (4.2.0)
|
|
298
320
|
unparser (0.8.0)
|
|
299
321
|
diff-lcs (~> 1.6)
|
|
300
322
|
parser (>= 3.3.0)
|
|
@@ -306,7 +328,7 @@ GEM
|
|
|
306
328
|
crack (>= 0.3.2)
|
|
307
329
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
308
330
|
webrick (1.9.1)
|
|
309
|
-
yard (0.9.
|
|
331
|
+
yard (0.9.45)
|
|
310
332
|
yard-activesupport-concern (0.0.1)
|
|
311
333
|
yard (>= 0.8)
|
|
312
334
|
yard-solargraph (0.1.0)
|
|
@@ -315,10 +337,11 @@ GEM
|
|
|
315
337
|
|
|
316
338
|
PLATFORMS
|
|
317
339
|
arm64-darwin-22
|
|
340
|
+
arm64-darwin-23
|
|
318
341
|
arm64-darwin-24
|
|
319
342
|
|
|
320
343
|
DEPENDENCIES
|
|
321
|
-
actionmailer
|
|
344
|
+
actionmailer (>= 7)
|
|
322
345
|
airborne
|
|
323
346
|
appraisal
|
|
324
347
|
bundler
|
|
@@ -329,7 +352,7 @@ DEPENDENCIES
|
|
|
329
352
|
rake
|
|
330
353
|
rbs
|
|
331
354
|
rspec
|
|
332
|
-
rspec-rails
|
|
355
|
+
rspec-rails (>= 7)
|
|
333
356
|
rspec-sidekiq
|
|
334
357
|
rubocop
|
|
335
358
|
rubocop-yard
|
|
@@ -6,6 +6,9 @@ module Solargraph
|
|
|
6
6
|
# rspec:
|
|
7
7
|
# let_methods:
|
|
8
8
|
# - let_it_be
|
|
9
|
+
# config_helper_files:
|
|
10
|
+
# - spec/spec_helper.rb
|
|
11
|
+
# - spec/rails_helper.rb
|
|
9
12
|
class Config
|
|
10
13
|
def initialize(solargraph_config = Solargraph::Workspace::Config.new('./'))
|
|
11
14
|
@solargraph_config = solargraph_config
|
|
@@ -25,8 +28,18 @@ module Solargraph
|
|
|
25
28
|
(Rspec::EXAMPLE_METHODS + additional_example_methods).map(&:to_sym)
|
|
26
29
|
end
|
|
27
30
|
|
|
31
|
+
# @return [Array<String>]
|
|
32
|
+
def config_helper_files
|
|
33
|
+
DEFAULT_CONFIG_HELPER_FILES + additional_config_helper_files
|
|
34
|
+
end
|
|
35
|
+
|
|
28
36
|
private
|
|
29
37
|
|
|
38
|
+
DEFAULT_CONFIG_HELPER_FILES = [
|
|
39
|
+
'spec/spec_helper.rb',
|
|
40
|
+
'spec/rails_helper.rb'
|
|
41
|
+
].freeze
|
|
42
|
+
|
|
30
43
|
# @return [Hash]
|
|
31
44
|
def rspec_raw_data
|
|
32
45
|
@rspec_raw_data ||= raw_data['rspec'] || {}
|
|
@@ -46,6 +59,13 @@ module Solargraph
|
|
|
46
59
|
(example_methods || []).map(&:to_sym)
|
|
47
60
|
end
|
|
48
61
|
|
|
62
|
+
# @return [Array<String>]
|
|
63
|
+
def additional_config_helper_files
|
|
64
|
+
# @type [Array<String>, nil]
|
|
65
|
+
config_files = rspec_raw_data['config_helper_files']
|
|
66
|
+
config_files || []
|
|
67
|
+
end
|
|
68
|
+
|
|
49
69
|
# @return [Hash]
|
|
50
70
|
def raw_data
|
|
51
71
|
@solargraph_config.raw_data
|
|
@@ -11,6 +11,7 @@ require_relative 'correctors/subject_method_corrector'
|
|
|
11
11
|
require_relative 'correctors/dsl_methods_corrector'
|
|
12
12
|
require_relative 'gems'
|
|
13
13
|
require_relative 'pin_factory'
|
|
14
|
+
require_relative 'rspec_configure'
|
|
14
15
|
|
|
15
16
|
module Solargraph
|
|
16
17
|
module Rspec
|
|
@@ -86,8 +87,16 @@ module Solargraph
|
|
|
86
87
|
root_example_group_namespace_pin: root_example_group_namespace_pin
|
|
87
88
|
)
|
|
88
89
|
pins += annotation_pins
|
|
90
|
+
|
|
91
|
+
# Add pins from RSpec.configure blocks
|
|
92
|
+
rspec_configure = RSpecConfigure.new(
|
|
93
|
+
config: config,
|
|
94
|
+
root_namespace_pin: root_example_group_namespace_pin
|
|
95
|
+
)
|
|
96
|
+
pins += rspec_configure.pins
|
|
97
|
+
|
|
89
98
|
# TODO: Include gem requires conditionally based on Gemfile definition
|
|
90
|
-
requires = Solargraph::Rspec::Gems.gem_names
|
|
99
|
+
requires = Solargraph::Rspec::Gems.gem_names + rspec_configure.extra_requires
|
|
91
100
|
|
|
92
101
|
if pins.any?
|
|
93
102
|
Solargraph.logger.debug(
|
|
@@ -68,7 +68,12 @@ module Solargraph
|
|
|
68
68
|
# @param pin [Solargraph::Pin::Base]
|
|
69
69
|
# @param new_closure [Solargraph::Pin::Closure]
|
|
70
70
|
def override_closure(pin, new_closure)
|
|
71
|
-
|
|
71
|
+
if pin.respond_to?(:closure=)
|
|
72
|
+
pin.closure = new_closure
|
|
73
|
+
return
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# work around older version of Solargraph
|
|
72
77
|
pin.instance_variable_set('@closure', new_closure)
|
|
73
78
|
pin.reset_generated!
|
|
74
79
|
|
|
@@ -104,8 +109,19 @@ module Solargraph
|
|
|
104
109
|
closure.location.filename
|
|
105
110
|
)
|
|
106
111
|
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
if closure.respond_to?(:location=)
|
|
113
|
+
closure.location = new_location
|
|
114
|
+
else
|
|
115
|
+
# work around older version of Solargraph
|
|
116
|
+
closure.instance_variable_set('@location', new_location)
|
|
117
|
+
closure.reset_generated!
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# find children of this pin and reset them, as they may have
|
|
121
|
+
# cached their binder or context based on the old closure
|
|
122
|
+
source_map.pins.select { |child_pin| child_pin.closure == closure }.each do |child_pin|
|
|
123
|
+
child_pin.reset_generated!
|
|
124
|
+
end
|
|
109
125
|
end
|
|
110
126
|
end
|
|
111
127
|
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'spec_configuration_walker'
|
|
4
|
+
require_relative 'pin_factory'
|
|
5
|
+
|
|
6
|
+
module Solargraph
|
|
7
|
+
module Rspec
|
|
8
|
+
# Handles RSpec.configure ... config.include parsing
|
|
9
|
+
# Provides pins for modules included globally via RSpec.configure
|
|
10
|
+
class RSpecConfigure
|
|
11
|
+
# @param config [Config]
|
|
12
|
+
# @param root_namespace_pin [Solargraph::Pin::Namespace]
|
|
13
|
+
def initialize(config:, root_namespace_pin:)
|
|
14
|
+
@config = config
|
|
15
|
+
@root_namespace_pin = root_namespace_pin
|
|
16
|
+
@included_modules = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @return [Array<Solargraph::Pin::Reference::Include>]
|
|
20
|
+
def pins
|
|
21
|
+
included_modules.map do |mod|
|
|
22
|
+
Solargraph::Pin::Reference::Include.new(
|
|
23
|
+
closure: @root_namespace_pin,
|
|
24
|
+
name: mod.module_name,
|
|
25
|
+
location: Solargraph::Location.new(mod.file, Solargraph::Parser.node_range(mod.node))
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [Array<String>]
|
|
31
|
+
def extra_requires
|
|
32
|
+
included_modules.map(&:file).uniq + support_files
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [Array<SpecConfigurationWalker::IncludedModule>]
|
|
36
|
+
def included_modules
|
|
37
|
+
@included_modules ||= parse_included_modules
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
# @return [Array<String>]
|
|
43
|
+
def support_files
|
|
44
|
+
Dir['spec/support/**/*.rb']
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @return [Array<SpecConfigurationWalker::IncludedModule>]
|
|
48
|
+
def parse_included_modules
|
|
49
|
+
modules = []
|
|
50
|
+
|
|
51
|
+
@config.config_helper_files.each do |file_path|
|
|
52
|
+
ast = Solargraph::Parser.parse(File.read(file_path), file_path)
|
|
53
|
+
walker = SpecConfigurationWalker.new(ast, file_path)
|
|
54
|
+
modules += walker.extract_included_modules
|
|
55
|
+
rescue Errno::ENOENT
|
|
56
|
+
# Ignore missing files - they may not exist in all projects
|
|
57
|
+
rescue StandardError => e
|
|
58
|
+
Solargraph.logger.error(
|
|
59
|
+
"[RSpec] [RSpecConfigure] Error reading helper file '#{file_path}': #{e.message}"
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
modules
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'walker'
|
|
4
|
+
require_relative 'spec_walker/full_constant_name'
|
|
5
|
+
|
|
6
|
+
module Solargraph
|
|
7
|
+
module Rspec
|
|
8
|
+
# Walks AST to find RSpec.configure blocks and extract included modules
|
|
9
|
+
class SpecConfigurationWalker
|
|
10
|
+
# @param ast [::Parser::AST::Node]
|
|
11
|
+
# @param filename [String] The file being parsed
|
|
12
|
+
def initialize(ast, filename)
|
|
13
|
+
@ast = ast
|
|
14
|
+
@filename = filename
|
|
15
|
+
@walker = Walker.new(ast)
|
|
16
|
+
@included_modules = []
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Represents a module included via config.include in RSpec.configure
|
|
20
|
+
# @param node [::Parser::AST::Node] The AST node for the include call
|
|
21
|
+
# @param file [String] The file where this module is included
|
|
22
|
+
# @param module_name [String] The fully qualified name of the included module
|
|
23
|
+
class IncludedModule < Struct.new(:node, :file, :module_name)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Walk the AST and extract included modules
|
|
27
|
+
# @return [Array<IncludedModule>]
|
|
28
|
+
def extract_included_modules
|
|
29
|
+
@walker.on :block, [:send] do |node|
|
|
30
|
+
send_node = node.children[0]
|
|
31
|
+
send_receiver = send_node.children[0]
|
|
32
|
+
|
|
33
|
+
# Check if this is RSpec.configure
|
|
34
|
+
next unless send_receiver&.type == :const
|
|
35
|
+
next unless send_receiver.children[1] == :RSpec
|
|
36
|
+
next unless send_node.children[1] == :configure
|
|
37
|
+
|
|
38
|
+
# Ensure block has arguments (the config parameter)
|
|
39
|
+
next if node.children[1].children.empty?
|
|
40
|
+
|
|
41
|
+
process_configure_block(node)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@walker.walk
|
|
45
|
+
@included_modules
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
# Process the RSpec.configure block to find config.include calls
|
|
51
|
+
# @param configure_block [::Parser::AST::Node]
|
|
52
|
+
# @return [void]
|
|
53
|
+
def process_configure_block(configure_block)
|
|
54
|
+
# Get the config variable name (e.g., |config| or |c|)
|
|
55
|
+
config_name = configure_block.children[1].children[0].children[0]
|
|
56
|
+
|
|
57
|
+
config_walker = Walker.new(configure_block)
|
|
58
|
+
config_walker.on :send, [:lvar, config_name] do |include_node|
|
|
59
|
+
# Look for config.include calls
|
|
60
|
+
next unless include_node.children[1] == :include
|
|
61
|
+
|
|
62
|
+
mod_node = include_node.children[2]
|
|
63
|
+
next unless mod_node.is_a?(::Parser::AST::Node)
|
|
64
|
+
next unless mod_node.type == :const
|
|
65
|
+
|
|
66
|
+
module_name = SpecWalker::FullConstantName.from_ast(mod_node)
|
|
67
|
+
@included_modules << IncludedModule.new(include_node, @filename, module_name)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
config_walker.walk
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solargraph-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lekë Mula
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-08-12 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: solargraph
|
|
@@ -57,6 +58,8 @@ files:
|
|
|
57
58
|
- lib/solargraph/rspec/correctors/subject_method_corrector.rb
|
|
58
59
|
- lib/solargraph/rspec/gems.rb
|
|
59
60
|
- lib/solargraph/rspec/pin_factory.rb
|
|
61
|
+
- lib/solargraph/rspec/rspec_configure.rb
|
|
62
|
+
- lib/solargraph/rspec/spec_configuration_walker.rb
|
|
60
63
|
- lib/solargraph/rspec/spec_walker.rb
|
|
61
64
|
- lib/solargraph/rspec/spec_walker/fake_let_method.rb
|
|
62
65
|
- lib/solargraph/rspec/spec_walker/full_constant_name.rb
|
|
@@ -69,11 +72,13 @@ files:
|
|
|
69
72
|
- release_gem.sh
|
|
70
73
|
- sig/solargraph/rspec.rbs
|
|
71
74
|
- solargraph-rspec.gemspec
|
|
75
|
+
homepage:
|
|
72
76
|
licenses:
|
|
73
77
|
- MIT
|
|
74
78
|
metadata:
|
|
75
79
|
source_code_uri: https://github.com/lekemula/solargraph-rspec
|
|
76
80
|
rubygems_mfa_required: 'true'
|
|
81
|
+
post_install_message:
|
|
77
82
|
rdoc_options: []
|
|
78
83
|
require_paths:
|
|
79
84
|
- lib
|
|
@@ -88,7 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
88
93
|
- !ruby/object:Gem::Version
|
|
89
94
|
version: '0'
|
|
90
95
|
requirements: []
|
|
91
|
-
rubygems_version: 3.
|
|
96
|
+
rubygems_version: 3.5.22
|
|
97
|
+
signing_key:
|
|
92
98
|
specification_version: 4
|
|
93
99
|
summary: Solargraph plugin supporting RSpec code completion
|
|
94
100
|
test_files: []
|