solargraph-rspec 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5246aadadd47bc9c4a53acbd1841f08187385c89b1a9a64bbb13d7d602f1522a
4
- data.tar.gz: b1b8dac88f82644833f309e0e2816d1950fd69ccef0b1a52093305bf6f61a08c
3
+ metadata.gz: 564e27d7603007e361d842c417b1baca62c166806ade9887b2c18971b30a2142
4
+ data.tar.gz: 9f4ce7fe9e22d8bfd6687732f54c7ec3b11b44af79c300ac4041819e3f594da8
5
5
  SHA512:
6
- metadata.gz: 828b1fdd6923a9621fcbee693d32048e1625feed89b47d2a7ce9931fbe9ee6a2fa58f4fb6bc2a3558955ce422da86ba1c940fa028c01a9f3cee9032b8f6737cb
7
- data.tar.gz: fd447792d52866c3e47bd0700d48630a390fcfe347d8f3e682a9c9dd29dd9c8f95e05a1ec02ecfba802a4883cb071f8c3db038d33fec7bb2f98913d235e282aa
6
+ metadata.gz: fc3f3fd7e8cde55700c1b19bf9dc460ebc4d302d1edda3ea0983d1ee275f43717191a39282b827f04811761123fff0127582485b08cb9411289f7684770dcdbf
7
+ data.tar.gz: 7eb9d7ae7f4b3df3ad9e201d1a127a43279f7a116199674b12f4eeb39846c2454ba7b0c5c7fc3c76d4eec5851f44d31a1452d4602974ca890213913b793abafc
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0
3
3
  NewCops: enable
4
4
 
5
5
  Style/StringLiterals:
data/Appraisals CHANGED
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'solargraph-0.50' do
4
- gem 'solargraph', '~> 0.50.0'
5
- end
6
-
7
- appraise 'solargraph-0.51' do
8
- gem 'solargraph', '~> 0.51.0'
3
+ appraise 'default' do
4
+ # default gems from Gemfile
9
5
  end
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2025-04-05
11
+
12
+ ### Changed
13
+
14
+ - Require ruby >=3 and update gems
15
+ - Re-use RSpec method definitions directly from source YARD definitions (#9)
16
+ - Fixes also class methods inheritance inside `context/describe` blocks
17
+
10
18
  ## v.0.4.1 - 2025-01-28
11
19
 
12
20
  ### Fixed
@@ -12,7 +12,6 @@ gem "rspec"
12
12
  gem "rubocop"
13
13
  gem "simplecov"
14
14
  gem "simplecov-cobertura"
15
- gem "solargraph", "~> 0.50.0"
16
15
 
17
16
  group :third_party_plugin_tests do
18
17
  gem "actionmailer"
@@ -1,41 +1,54 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- solargraph-rspec (0.4.0)
5
- solargraph (~> 0.49, >= 0.49.0)
4
+ solargraph-rspec (0.4.1)
5
+ solargraph (~> 0.52, >= 0.52.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionmailer (6.1.7.10)
11
- actionpack (= 6.1.7.10)
12
- actionview (= 6.1.7.10)
13
- activejob (= 6.1.7.10)
14
- activesupport (= 6.1.7.10)
10
+ actionmailer (7.1.5.1)
11
+ actionpack (= 7.1.5.1)
12
+ actionview (= 7.1.5.1)
13
+ activejob (= 7.1.5.1)
14
+ activesupport (= 7.1.5.1)
15
15
  mail (~> 2.5, >= 2.5.4)
16
- rails-dom-testing (~> 2.0)
17
- actionpack (6.1.7.10)
18
- actionview (= 6.1.7.10)
19
- activesupport (= 6.1.7.10)
20
- rack (~> 2.0, >= 2.0.9)
16
+ net-imap
17
+ net-pop
18
+ net-smtp
19
+ rails-dom-testing (~> 2.2)
20
+ actionpack (7.1.5.1)
21
+ actionview (= 7.1.5.1)
22
+ activesupport (= 7.1.5.1)
23
+ nokogiri (>= 1.8.5)
24
+ racc
25
+ rack (>= 2.2.4)
26
+ rack-session (>= 1.0.1)
21
27
  rack-test (>= 0.6.3)
22
- rails-dom-testing (~> 2.0)
23
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
24
- actionview (6.1.7.10)
25
- activesupport (= 6.1.7.10)
28
+ rails-dom-testing (~> 2.2)
29
+ rails-html-sanitizer (~> 1.6)
30
+ actionview (7.1.5.1)
31
+ activesupport (= 7.1.5.1)
26
32
  builder (~> 3.1)
27
- erubi (~> 1.4)
28
- rails-dom-testing (~> 2.0)
29
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
30
- activejob (6.1.7.10)
31
- activesupport (= 6.1.7.10)
33
+ erubi (~> 1.11)
34
+ rails-dom-testing (~> 2.2)
35
+ rails-html-sanitizer (~> 1.6)
36
+ activejob (7.1.5.1)
37
+ activesupport (= 7.1.5.1)
32
38
  globalid (>= 0.3.6)
33
- activesupport (6.1.7.10)
39
+ activesupport (7.1.5.1)
40
+ base64
41
+ benchmark (>= 0.3)
42
+ bigdecimal
34
43
  concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ connection_pool (>= 2.2.5)
45
+ drb
35
46
  i18n (>= 1.6, < 2)
47
+ logger (>= 1.4.2)
36
48
  minitest (>= 5.1)
49
+ mutex_m
50
+ securerandom (>= 0.3)
37
51
  tzinfo (~> 2.0)
38
- zeitwerk (~> 2.3)
39
52
  addressable (2.8.7)
40
53
  public_suffix (>= 2.0.2, < 7.0)
41
54
  airborne (0.3.7)
@@ -48,8 +61,9 @@ GEM
48
61
  bundler
49
62
  rake
50
63
  thor (>= 0.14.0)
51
- ast (2.4.2)
64
+ ast (2.4.3)
52
65
  backport (1.2.0)
66
+ base64 (0.2.0)
53
67
  benchmark (0.4.0)
54
68
  bigdecimal (3.1.9)
55
69
  builder (3.3.0)
@@ -62,13 +76,13 @@ GEM
62
76
  rexml
63
77
  crass (1.0.6)
64
78
  date (3.4.1)
65
- debug (1.8.0)
66
- irb (>= 1.5.0)
67
- reline (>= 0.3.1)
68
- diff-lcs (1.5.1)
79
+ debug (1.10.0)
80
+ irb (~> 1.10)
81
+ reline (>= 0.3.8)
82
+ diff-lcs (1.6.0)
69
83
  docile (1.4.1)
70
- domain_name (0.5.20190701)
71
- unf (>= 0.0.5, < 1.0.0)
84
+ domain_name (0.6.20240107)
85
+ drb (2.2.1)
72
86
  erubi (1.13.1)
73
87
  globalid (1.2.1)
74
88
  activesupport (>= 6.1)
@@ -79,15 +93,19 @@ GEM
79
93
  i18n (1.14.7)
80
94
  concurrent-ruby (~> 1.0)
81
95
  io-console (0.8.0)
82
- irb (1.6.3)
83
- reline (>= 0.3.0)
96
+ irb (1.15.1)
97
+ pp (>= 0.6.0)
98
+ rdoc (>= 4.0.0)
99
+ reline (>= 0.4.2)
84
100
  jaro_winkler (1.6.0)
85
- json (2.7.6)
101
+ json (2.10.2)
86
102
  kramdown (2.5.1)
87
103
  rexml (>= 3.3.9)
88
104
  kramdown-parser-gfm (1.1.0)
89
105
  kramdown (~> 2.0)
90
- logger (1.6.5)
106
+ language_server-protocol (3.17.0.4)
107
+ lint_roller (1.1.0)
108
+ logger (1.6.6)
91
109
  loofah (2.24.0)
92
110
  crass (~> 1.0.2)
93
111
  nokogiri (>= 1.12.0)
@@ -97,61 +115,80 @@ GEM
97
115
  net-pop
98
116
  net-smtp
99
117
  method_source (1.1.0)
100
- mime-types (3.6.0)
118
+ mime-types (3.6.1)
101
119
  logger
102
120
  mime-types-data (~> 3.2015)
103
- mime-types-data (3.2025.0107)
121
+ mime-types-data (3.2025.0318)
104
122
  mini_mime (1.1.5)
105
- minitest (5.25.4)
106
- net-imap (0.3.7)
123
+ minitest (5.25.5)
124
+ mutex_m (0.3.0)
125
+ net-imap (0.4.19)
107
126
  date
108
127
  net-protocol
109
128
  net-pop (0.1.2)
110
129
  net-protocol
111
130
  net-protocol (0.2.2)
112
131
  timeout
113
- net-smtp (0.5.0)
132
+ net-smtp (0.5.1)
114
133
  net-protocol
115
134
  netrc (0.11.0)
116
- nokogiri (1.13.10-arm64-darwin)
135
+ nokogiri (1.17.2-arm64-darwin)
117
136
  racc (~> 1.4)
118
137
  observer (0.1.2)
119
138
  optparse (0.6.0)
120
139
  ostruct (0.6.1)
121
- parallel (1.24.0)
122
- parser (3.3.7.0)
140
+ parallel (1.26.3)
141
+ parser (3.3.7.2)
123
142
  ast (~> 2.4.1)
124
143
  racc
144
+ pp (0.6.2)
145
+ prettyprint
146
+ prettyprint (0.2.0)
125
147
  profile-viewer (0.0.4)
126
148
  optparse
127
149
  webrick
128
- pry (0.13.1)
150
+ pry (0.14.2)
129
151
  coderay (~> 1.1)
130
152
  method_source (~> 1.0)
131
- pry-byebug (3.9.0)
153
+ pry-byebug (3.10.1)
132
154
  byebug (~> 11.0)
133
- pry (~> 0.13.0)
134
- public_suffix (5.1.1)
155
+ pry (>= 0.13, < 0.15)
156
+ psych (5.2.3)
157
+ date
158
+ stringio
159
+ public_suffix (6.0.1)
135
160
  racc (1.8.1)
136
- rack (2.2.10)
161
+ rack (2.2.13)
162
+ rack-session (1.0.2)
163
+ rack (< 3)
137
164
  rack-test (1.1.0)
138
165
  rack (>= 1.0, < 3)
166
+ rackup (1.0.1)
167
+ rack (< 3)
168
+ webrick
139
169
  rails-dom-testing (2.2.0)
140
170
  activesupport (>= 5.0.0)
141
171
  minitest
142
172
  nokogiri (>= 1.6)
143
- rails-html-sanitizer (1.5.0)
144
- loofah (~> 2.19, >= 2.19.1)
145
- railties (6.1.7.10)
146
- actionpack (= 6.1.7.10)
147
- activesupport (= 6.1.7.10)
148
- method_source
173
+ rails-html-sanitizer (1.6.2)
174
+ loofah (~> 2.21)
175
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
176
+ railties (7.1.5.1)
177
+ actionpack (= 7.1.5.1)
178
+ activesupport (= 7.1.5.1)
179
+ irb
180
+ rackup (>= 1.0.0)
149
181
  rake (>= 12.2)
150
- thor (~> 1.0)
182
+ thor (~> 1.0, >= 1.2.2)
183
+ zeitwerk (~> 2.6)
151
184
  rainbow (3.1.1)
152
185
  rake (13.2.1)
153
- rbs (3.1.3)
154
- redis (4.8.1)
186
+ rbs (3.6.1)
187
+ logger
188
+ rdoc (6.12.0)
189
+ psych (>= 4.0.0)
190
+ redis-client (0.24.0)
191
+ connection_pool
155
192
  regexp_parser (2.10.0)
156
193
  reline (0.6.0)
157
194
  io-console (~> 0.5)
@@ -162,12 +199,12 @@ GEM
162
199
  netrc (~> 0.8)
163
200
  reverse_markdown (3.0.0)
164
201
  nokogiri
165
- rexml (3.4.0)
202
+ rexml (3.4.1)
166
203
  rspec (3.13.0)
167
204
  rspec-core (~> 3.13.0)
168
205
  rspec-expectations (~> 3.13.0)
169
206
  rspec-mocks (~> 3.13.0)
170
- rspec-core (3.13.2)
207
+ rspec-core (3.13.3)
171
208
  rspec-support (~> 3.13.0)
172
209
  rspec-expectations (3.13.3)
173
210
  diff-lcs (>= 1.2.0, < 2.0)
@@ -175,39 +212,43 @@ GEM
175
212
  rspec-mocks (3.13.2)
176
213
  diff-lcs (>= 1.2.0, < 2.0)
177
214
  rspec-support (~> 3.13.0)
178
- rspec-rails (6.1.5)
179
- actionpack (>= 6.1)
180
- activesupport (>= 6.1)
181
- railties (>= 6.1)
215
+ rspec-rails (7.1.1)
216
+ actionpack (>= 7.0)
217
+ activesupport (>= 7.0)
218
+ railties (>= 7.0)
182
219
  rspec-core (~> 3.13)
183
220
  rspec-expectations (~> 3.13)
184
221
  rspec-mocks (~> 3.13)
185
222
  rspec-support (~> 3.13)
186
- rspec-sidekiq (4.0.2)
223
+ rspec-sidekiq (5.1.0)
187
224
  rspec-core (~> 3.0)
188
225
  rspec-expectations (~> 3.0)
189
226
  rspec-mocks (~> 3.0)
190
- sidekiq (>= 5, < 8)
227
+ sidekiq (>= 5, < 9)
191
228
  rspec-support (3.13.2)
192
- rubocop (1.50.2)
229
+ rubocop (1.74.0)
193
230
  json (~> 2.3)
231
+ language_server-protocol (~> 3.17.0.2)
232
+ lint_roller (~> 1.1.0)
194
233
  parallel (~> 1.10)
195
- parser (>= 3.2.0.0)
234
+ parser (>= 3.3.0.2)
196
235
  rainbow (>= 2.2.2, < 4.0)
197
- regexp_parser (>= 1.8, < 3.0)
198
- rexml (>= 3.2.5, < 4.0)
199
- rubocop-ast (>= 1.28.0, < 2.0)
236
+ regexp_parser (>= 2.9.3, < 3.0)
237
+ rubocop-ast (>= 1.38.0, < 2.0)
200
238
  ruby-progressbar (~> 1.7)
201
- unicode-display_width (>= 2.4.0, < 3.0)
202
- rubocop-ast (1.30.0)
203
- parser (>= 3.2.1.0)
239
+ unicode-display_width (>= 2.4.0, < 4.0)
240
+ rubocop-ast (1.41.0)
241
+ parser (>= 3.3.7.2)
204
242
  ruby-progressbar (1.13.0)
205
- shoulda-matchers (5.3.0)
243
+ securerandom (0.3.2)
244
+ shoulda-matchers (6.4.0)
206
245
  activesupport (>= 5.2.0)
207
- sidekiq (6.5.12)
208
- connection_pool (>= 2.2.5, < 3)
209
- rack (~> 2.0)
210
- redis (>= 4.5.0, < 5)
246
+ sidekiq (7.3.9)
247
+ base64
248
+ connection_pool (>= 2.3.0)
249
+ logger
250
+ rack (>= 2.2.4)
251
+ redis-client (>= 0.22.2)
211
252
  simplecov (0.22.0)
212
253
  docile (~> 1.1)
213
254
  simplecov-html (~> 0.11)
@@ -217,7 +258,7 @@ GEM
217
258
  simplecov (~> 0.19)
218
259
  simplecov-html (0.13.1)
219
260
  simplecov_json_formatter (0.1.4)
220
- solargraph (0.51.1)
261
+ solargraph (0.52.0)
221
262
  backport (~> 1.2)
222
263
  benchmark
223
264
  bundler (~> 2.0)
@@ -235,23 +276,28 @@ GEM
235
276
  thor (~> 1.0)
236
277
  tilt (~> 2.0)
237
278
  yard (~> 0.9, >= 0.9.24)
279
+ yard-solargraph (~> 0.1)
280
+ stringio (3.1.5)
238
281
  thor (1.3.2)
239
282
  tilt (2.6.0)
240
283
  timeout (0.4.3)
241
284
  tzinfo (2.0.6)
242
285
  concurrent-ruby (~> 1.0)
243
- unf (0.2.0)
244
- unicode-display_width (2.6.0)
245
- webmock (3.24.0)
286
+ unicode-display_width (3.1.4)
287
+ unicode-emoji (~> 4.0, >= 4.0.4)
288
+ unicode-emoji (4.0.4)
289
+ webmock (3.25.1)
246
290
  addressable (>= 2.8.0)
247
291
  crack (>= 0.3.2)
248
292
  hashdiff (>= 0.4.0, < 2.0.0)
249
293
  webrick (1.9.1)
250
294
  yard (0.9.37)
295
+ yard-solargraph (0.1.0)
296
+ yard (~> 0.9)
251
297
  zeitwerk (2.6.18)
252
298
 
253
299
  PLATFORMS
254
- arm64-darwin-22
300
+ arm64-darwin-24
255
301
 
256
302
  DEPENDENCIES
257
303
  actionmailer
@@ -269,7 +315,6 @@ DEPENDENCIES
269
315
  shoulda-matchers
270
316
  simplecov
271
317
  simplecov-cobertura
272
- solargraph (~> 0.51.0)
273
318
  solargraph-rspec!
274
319
  webmock
275
320
 
@@ -6,91 +6,29 @@ require 'yard'
6
6
  module Solargraph
7
7
  module Rspec
8
8
  module Correctors
9
- # Includes DSL method helpers in the example group block for completion (ie. it, before, let, subject, etc.)
9
+ # Corrects RSpec DSL methods in the specs by adding superclass references to the namespace pins (ie. contexts).
10
+ # The DSLs methods are generated by rspec-core YARD annotations defined in [RSpec::Core::ExampleGroup]
10
11
  class DslMethodsCorrector < Base
11
- # @return [Array<YARD::CodeObjects::Base>]
12
- def self.rspec_yardoc_tags
13
- @rspec_yardoc_tags ||= begin
14
- spec = Gem::Specification.find_by_name('rspec-core')
15
- require_paths = spec.require_paths.map { |path| File.join(spec.full_gem_path, path) }
16
- Solargraph.logger.debug "[RSpec] Loading YARD registry for rspec-core from #{require_paths}"
17
- YARD::Registry.load(require_paths, true)
18
- YARD::Registry.all
19
- end
20
- end
21
-
22
- # @param source_map [Solargraph::SourceMap]
12
+ # @param _source_map [Solargraph::SourceMap]
23
13
  # @return [void]
24
14
  def correct(_source_map)
25
15
  rspec_walker.after_walk do
26
- namespace_pins.each do |namespace_pin|
27
- add_pins(context_dsl_methods(namespace_pin))
28
- add_pins(methods_with_example_binding(namespace_pin))
16
+ namespace_pins.each_with_index do |namespace_pin, index|
17
+ super_class = if index.zero?
18
+ 'RSpec::Core::ExampleGroup'
19
+ else
20
+ namespace_pins[index - 1].path
21
+ end
22
+ add_pin(
23
+ Pin::Reference::Superclass.new(
24
+ location: namespace_pin.location,
25
+ closure: namespace_pin,
26
+ name: super_class
27
+ )
28
+ )
29
29
  end
30
30
  end
31
31
  end
32
-
33
- private
34
-
35
- # RSpec executes example and hook blocks (eg. it, before, after)in the context of the example group.
36
- # Tag @yieldsef changes the binding of the block to correct class.
37
- # @return [Array<Solargraph::Pin::Method>]
38
- def methods_with_example_binding(namespace_pin)
39
- rspec_context_block_methods.map do |method|
40
- # TODO: Add location from YARD registry and documentation for other methods not just example group methods.
41
- PinFactory.build_public_method(
42
- namespace_pin,
43
- method.to_s,
44
- comments: [example_group_documentation(method), "@yieldself [#{namespace_pin.path}]"],
45
- scope: :class
46
- )
47
- end
48
- end
49
-
50
- # TODO: DSL methods should be defined once in the root example group and extended to all example groups.
51
- # Fix this once Solargraph supports extending class methods.
52
- # @param namespace_pin [Solargraph::Pin::Base]
53
- # @return [Array<Solargraph::Pin::Base>]
54
- def context_dsl_methods(namespace_pin)
55
- Rspec::CONTEXT_METHODS.map do |method|
56
- PinFactory.build_public_method(
57
- namespace_pin,
58
- method.to_s,
59
- scope: :class
60
- )
61
- end
62
- end
63
-
64
- # @param method [String]
65
- # @return [String]
66
- def example_group_documentation(method)
67
- return unless Rspec::EXAMPLE_METHODS.include?(method)
68
-
69
- yardoc = rspec_yardoc_tags_at("RSpec::Core::ExampleGroup.#{method}")
70
-
71
- unless yardoc
72
- Solargraph.logger.warn "[RSpec] YARD documentation not found for RSpec::Core::ExampleGroup.#{method}"
73
- return
74
- end
75
-
76
- yardoc.docstring.all
77
- end
78
-
79
- # @param method [String]
80
- # @return [YARD::CodeObjects::MethodObject, nil]
81
- def rspec_yardoc_tags_at(method_path)
82
- self.class.rspec_yardoc_tags.find { |tag| tag.path == method_path }
83
- end
84
-
85
- # @return [Array<String>]
86
- def rspec_context_block_methods
87
- config.let_methods + Rspec::HOOK_METHODS + Rspec::EXAMPLE_METHODS
88
- end
89
-
90
- # @return [Solargraph::Rspec::Config]
91
- def config
92
- Solargraph::Rspec::Convention.config
93
- end
94
32
  end
95
33
  end
96
34
  end
@@ -4,8 +4,8 @@ module Solargraph
4
4
  module Rspec
5
5
  class SpecWalker
6
6
  class FakeLetMethod
7
- MATCH_DO_END = /.*? do(.*)end/m.freeze
8
- MATCH_CURLY = /{(.*)}/m.freeze
7
+ MATCH_DO_END = /.*? do(.*)end/m
8
+ MATCH_CURLY = /{(.*)}/m
9
9
 
10
10
  class << self
11
11
  # Transforms let block to method ast node
@@ -14,41 +14,6 @@ module Solargraph
14
14
  def transform_block(block_ast, code, method_name = nil)
15
15
  method_name ||= NodeTypes.let_method_name(block_ast)
16
16
 
17
- if Solargraph::Parser.rubyvm?
18
- rubyvm_transform_block(block_ast, code, method_name)
19
- else
20
- parser_transform_block(block_ast, code, method_name)
21
- end
22
- end
23
-
24
- private
25
-
26
- # @param block_ast [RubyVM::AbstractSyntaxTree::Node]
27
- # @return [RubyVM::AbstractSyntaxTree::Node, nil]
28
- def rubyvm_transform_block(block_ast, code, method_name = nil)
29
- block_body = block_ast.children[1]
30
- let_definition_code = code.lines[block_body.first_lineno - 1..block_body.last_lineno - 1].join
31
- match_do_end = let_definition_code.match(MATCH_DO_END)&.captures&.first || ''
32
- match_curly = let_definition_code.match(MATCH_CURLY)&.captures&.first || ''
33
- method_body = [match_do_end, match_curly].max_by(&:length).strip
34
-
35
- ast = RubyVM::AbstractSyntaxTree.parse <<~RUBY
36
- def #{method_name}
37
- #{method_body}
38
- end
39
- RUBY
40
-
41
- ast.children[2]
42
- rescue SyntaxError => e
43
- Solargraph.logger.warn "[RSpec] Failed to build fake let method: #{e.message}, \
44
- \n\nlet_definition_code: \n```\n#{let_definition_code}\n```, \
45
- \n\nmethod_body: \n```\n#{method_body}\n```, \
46
- \nast: #{block_ast.inspect}"
47
- end
48
-
49
- # @param block_ast [RubyVM::AbstractSyntaxTree::Node]
50
- # @return [::Parser::AST::Node]
51
- def parser_transform_block(block_ast, code, method_name = nil)
52
17
  code_lines = code.split("\n")
53
18
  # extract let definition block body code
54
19
  first_line = code_lines[block_ast.first_lineno - 1]
@@ -75,7 +75,7 @@ module Solargraph
75
75
  # @param block_ast [RubyVM::AbstractSyntaxTree::Node]
76
76
  # @return [String]
77
77
  def self.let_method_name(block_ast)
78
- block_ast.children[0].children[1]&.children&.[](0)&.children&.[](0)&.to_s
78
+ block_ast.children[0].children[1]&.children&.[](0)&.children&.[](0)&.to_s # rubocop:disable Style/SafeNavigationChainLength
79
79
  end
80
80
  end
81
81
  end
@@ -33,7 +33,7 @@ module Solargraph
33
33
  return 'Anonymous'.dup if name.empty?
34
34
 
35
35
  # Convert to CamelCase.
36
- name = +" #{name}"
36
+ name = " #{name}"
37
37
  name.gsub!(/[^0-9a-zA-Z]+([0-9a-zA-Z])/) do
38
38
  match = ::Regexp.last_match[1]
39
39
  match.upcase!
@@ -14,6 +14,7 @@ module Solargraph
14
14
  def initialize(source_map:, config:)
15
15
  @source_map = source_map
16
16
  @config = config
17
+ # TODO: Implement SpecWalker with parser gem using default AST from `source_map.source.node`
17
18
  @walker = Rspec::Walker.new(ruby_vm_node(source_map))
18
19
  @handlers = {
19
20
  on_described_class: [],
@@ -211,17 +212,10 @@ module Solargraph
211
212
  end
212
213
  end
213
214
 
214
- # HACK: Make it work for ruby '>= 3.4.9' and solargraph '>= 0.51.0'
215
- # https://github.com/castwide/solargraph/pull/739 disables the `rubyvm` for Ruby 3.4
216
- # TODO: Implement SpecWalker with parser gem
217
215
  # @param source_map [SourceMap]
218
216
  # @return [RubyVM::AbstractSyntaxTree::Node]
219
217
  def ruby_vm_node(source_map)
220
- if Solargraph::Parser.rubyvm?
221
- source_map.source.node
222
- else
223
- RubyVM::AbstractSyntaxTree.parse(source_map.source.code)
224
- end
218
+ RubyVM::AbstractSyntaxTree.parse(source_map.source.code)
225
219
  end
226
220
  end
227
221
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Solargraph
4
4
  module Rspec
5
- VERSION = '0.4.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -71,7 +71,7 @@ module Solargraph
71
71
  def initialize(ast, comments = {})
72
72
  @comments = comments
73
73
  @ast = ast
74
- @hooks = Hash.new([])
74
+ @hooks = Hash.new { |h, k| h[k] = [] }
75
75
  end
76
76
 
77
77
  def on(node_type, args = [], &block)
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'RSpec is a testing tool of choice for many Ruby developers. ' \
13
13
  'This plugin provides code completion and other features for RSpec files in Solargraph.'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 2.6.0'
15
+ spec.required_ruby_version = '>= 3.0'
16
16
 
17
17
  spec.metadata['source_code_uri'] = 'https://github.com/lekemula/solargraph-rspec'
18
18
 
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
30
 
31
- spec.add_runtime_dependency 'solargraph', '~> 0.49', '>= 0.49.0'
31
+ spec.add_dependency 'solargraph', '~> 0.52', '>= 0.52.0'
32
32
 
33
33
  # For more information and examples about making a new gem, check out our
34
34
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lekë Mula
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-01-28 00:00:00.000000000 Z
10
+ date: 2025-04-05 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: solargraph
@@ -16,20 +15,20 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '0.49'
18
+ version: '0.52'
20
19
  - - ">="
21
20
  - !ruby/object:Gem::Version
22
- version: 0.49.0
21
+ version: 0.52.0
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - "~>"
28
27
  - !ruby/object:Gem::Version
29
- version: '0.49'
28
+ version: '0.52'
30
29
  - - ">="
31
30
  - !ruby/object:Gem::Version
32
- version: 0.49.0
31
+ version: 0.52.0
33
32
  description: RSpec is a testing tool of choice for many Ruby developers. This plugin
34
33
  provides code completion and other features for RSpec files in Solargraph.
35
34
  email:
@@ -52,10 +51,8 @@ files:
52
51
  - doc/images/vim_demo.gif
53
52
  - doc/images/vscode_demo.gif
54
53
  - gemfiles/.bundle/config
55
- - gemfiles/solargraph_0.50.gemfile
56
- - gemfiles/solargraph_0.50.gemfile.lock
57
- - gemfiles/solargraph_0.51.gemfile
58
- - gemfiles/solargraph_0.51.gemfile.lock
54
+ - gemfiles/default.gemfile
55
+ - gemfiles/default.gemfile.lock
59
56
  - lib/solargraph-rspec.rb
60
57
  - lib/solargraph/rspec/annotations.rb
61
58
  - lib/solargraph/rspec/config.rb
@@ -80,13 +77,11 @@ files:
80
77
  - lib/solargraph_rspec.rb
81
78
  - sig/solargraph/rspec.rbs
82
79
  - solargraph-rspec.gemspec
83
- homepage:
84
80
  licenses:
85
81
  - MIT
86
82
  metadata:
87
83
  source_code_uri: https://github.com/lekemula/solargraph-rspec
88
84
  rubygems_mfa_required: 'true'
89
- post_install_message:
90
85
  rdoc_options: []
91
86
  require_paths:
92
87
  - lib
@@ -94,15 +89,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
89
  requirements:
95
90
  - - ">="
96
91
  - !ruby/object:Gem::Version
97
- version: 2.6.0
92
+ version: '3.0'
98
93
  required_rubygems_version: !ruby/object:Gem::Requirement
99
94
  requirements:
100
95
  - - ">="
101
96
  - !ruby/object:Gem::Version
102
97
  version: '0'
103
98
  requirements: []
104
- rubygems_version: 3.2.3
105
- signing_key:
99
+ rubygems_version: 3.6.3
106
100
  specification_version: 4
107
101
  summary: Solargraph plugin supporting RSpec code completion
108
102
  test_files: []
@@ -1,274 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- solargraph-rspec (0.4.0)
5
- solargraph (~> 0.49, >= 0.49.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- actionmailer (6.1.7.10)
11
- actionpack (= 6.1.7.10)
12
- actionview (= 6.1.7.10)
13
- activejob (= 6.1.7.10)
14
- activesupport (= 6.1.7.10)
15
- mail (~> 2.5, >= 2.5.4)
16
- rails-dom-testing (~> 2.0)
17
- actionpack (6.1.7.10)
18
- actionview (= 6.1.7.10)
19
- activesupport (= 6.1.7.10)
20
- rack (~> 2.0, >= 2.0.9)
21
- rack-test (>= 0.6.3)
22
- rails-dom-testing (~> 2.0)
23
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
24
- actionview (6.1.7.10)
25
- activesupport (= 6.1.7.10)
26
- builder (~> 3.1)
27
- erubi (~> 1.4)
28
- rails-dom-testing (~> 2.0)
29
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
30
- activejob (6.1.7.10)
31
- activesupport (= 6.1.7.10)
32
- globalid (>= 0.3.6)
33
- activesupport (6.1.7.10)
34
- concurrent-ruby (~> 1.0, >= 1.0.2)
35
- i18n (>= 1.6, < 2)
36
- minitest (>= 5.1)
37
- tzinfo (~> 2.0)
38
- zeitwerk (~> 2.3)
39
- addressable (2.8.7)
40
- public_suffix (>= 2.0.2, < 7.0)
41
- airborne (0.3.7)
42
- activesupport
43
- rack
44
- rack-test (>= 1.1.0, < 2.0)
45
- rest-client (>= 2.0.2, < 3.0)
46
- rspec (~> 3.8)
47
- appraisal (2.5.0)
48
- bundler
49
- rake
50
- thor (>= 0.14.0)
51
- ast (2.4.2)
52
- backport (1.2.0)
53
- benchmark (0.4.0)
54
- bigdecimal (3.1.9)
55
- builder (3.3.0)
56
- byebug (11.1.3)
57
- coderay (1.1.3)
58
- concurrent-ruby (1.3.5)
59
- connection_pool (2.5.0)
60
- crack (1.0.0)
61
- bigdecimal
62
- rexml
63
- crass (1.0.6)
64
- date (3.4.1)
65
- debug (1.8.0)
66
- irb (>= 1.5.0)
67
- reline (>= 0.3.1)
68
- diff-lcs (1.5.1)
69
- docile (1.4.1)
70
- domain_name (0.5.20190701)
71
- unf (>= 0.0.5, < 1.0.0)
72
- e2mmap (0.1.0)
73
- erubi (1.13.1)
74
- globalid (1.2.1)
75
- activesupport (>= 6.1)
76
- hashdiff (1.1.2)
77
- http-accept (1.7.0)
78
- http-cookie (1.0.8)
79
- domain_name (~> 0.5)
80
- i18n (1.14.7)
81
- concurrent-ruby (~> 1.0)
82
- io-console (0.8.0)
83
- irb (1.6.3)
84
- reline (>= 0.3.0)
85
- jaro_winkler (1.6.0)
86
- json (2.7.6)
87
- kramdown (2.5.1)
88
- rexml (>= 3.3.9)
89
- kramdown-parser-gfm (1.1.0)
90
- kramdown (~> 2.0)
91
- logger (1.6.5)
92
- loofah (2.24.0)
93
- crass (~> 1.0.2)
94
- nokogiri (>= 1.12.0)
95
- mail (2.8.1)
96
- mini_mime (>= 0.1.1)
97
- net-imap
98
- net-pop
99
- net-smtp
100
- method_source (1.1.0)
101
- mime-types (3.6.0)
102
- logger
103
- mime-types-data (~> 3.2015)
104
- mime-types-data (3.2025.0107)
105
- mini_mime (1.1.5)
106
- minitest (5.25.4)
107
- net-imap (0.3.7)
108
- date
109
- net-protocol
110
- net-pop (0.1.2)
111
- net-protocol
112
- net-protocol (0.2.2)
113
- timeout
114
- net-smtp (0.5.0)
115
- net-protocol
116
- netrc (0.11.0)
117
- nokogiri (1.13.10-arm64-darwin)
118
- racc (~> 1.4)
119
- optparse (0.6.0)
120
- parallel (1.24.0)
121
- parser (3.3.7.0)
122
- ast (~> 2.4.1)
123
- racc
124
- profile-viewer (0.0.4)
125
- optparse
126
- webrick
127
- pry (0.13.1)
128
- coderay (~> 1.1)
129
- method_source (~> 1.0)
130
- pry-byebug (3.9.0)
131
- byebug (~> 11.0)
132
- pry (~> 0.13.0)
133
- public_suffix (5.1.1)
134
- racc (1.8.1)
135
- rack (2.2.10)
136
- rack-test (1.1.0)
137
- rack (>= 1.0, < 3)
138
- rails-dom-testing (2.2.0)
139
- activesupport (>= 5.0.0)
140
- minitest
141
- nokogiri (>= 1.6)
142
- rails-html-sanitizer (1.5.0)
143
- loofah (~> 2.19, >= 2.19.1)
144
- railties (6.1.7.10)
145
- actionpack (= 6.1.7.10)
146
- activesupport (= 6.1.7.10)
147
- method_source
148
- rake (>= 12.2)
149
- thor (~> 1.0)
150
- rainbow (3.1.1)
151
- rake (13.2.1)
152
- rbs (2.8.4)
153
- redis (4.8.1)
154
- regexp_parser (2.10.0)
155
- reline (0.6.0)
156
- io-console (~> 0.5)
157
- rest-client (2.1.0)
158
- http-accept (>= 1.7.0, < 2.0)
159
- http-cookie (>= 1.0.2, < 2.0)
160
- mime-types (>= 1.16, < 4.0)
161
- netrc (~> 0.8)
162
- reverse_markdown (2.1.1)
163
- nokogiri
164
- rexml (3.4.0)
165
- rspec (3.13.0)
166
- rspec-core (~> 3.13.0)
167
- rspec-expectations (~> 3.13.0)
168
- rspec-mocks (~> 3.13.0)
169
- rspec-core (3.13.2)
170
- rspec-support (~> 3.13.0)
171
- rspec-expectations (3.13.3)
172
- diff-lcs (>= 1.2.0, < 2.0)
173
- rspec-support (~> 3.13.0)
174
- rspec-mocks (3.13.2)
175
- diff-lcs (>= 1.2.0, < 2.0)
176
- rspec-support (~> 3.13.0)
177
- rspec-rails (6.1.5)
178
- actionpack (>= 6.1)
179
- activesupport (>= 6.1)
180
- railties (>= 6.1)
181
- rspec-core (~> 3.13)
182
- rspec-expectations (~> 3.13)
183
- rspec-mocks (~> 3.13)
184
- rspec-support (~> 3.13)
185
- rspec-sidekiq (4.0.2)
186
- rspec-core (~> 3.0)
187
- rspec-expectations (~> 3.0)
188
- rspec-mocks (~> 3.0)
189
- sidekiq (>= 5, < 8)
190
- rspec-support (3.13.2)
191
- rubocop (1.50.2)
192
- json (~> 2.3)
193
- parallel (~> 1.10)
194
- parser (>= 3.2.0.0)
195
- rainbow (>= 2.2.2, < 4.0)
196
- regexp_parser (>= 1.8, < 3.0)
197
- rexml (>= 3.2.5, < 4.0)
198
- rubocop-ast (>= 1.28.0, < 2.0)
199
- ruby-progressbar (~> 1.7)
200
- unicode-display_width (>= 2.4.0, < 3.0)
201
- rubocop-ast (1.30.0)
202
- parser (>= 3.2.1.0)
203
- ruby-progressbar (1.13.0)
204
- shoulda-matchers (5.3.0)
205
- activesupport (>= 5.2.0)
206
- sidekiq (6.5.12)
207
- connection_pool (>= 2.2.5, < 3)
208
- rack (~> 2.0)
209
- redis (>= 4.5.0, < 5)
210
- simplecov (0.22.0)
211
- docile (~> 1.1)
212
- simplecov-html (~> 0.11)
213
- simplecov_json_formatter (~> 0.1)
214
- simplecov-cobertura (2.1.0)
215
- rexml
216
- simplecov (~> 0.19)
217
- simplecov-html (0.13.1)
218
- simplecov_json_formatter (0.1.4)
219
- solargraph (0.50.0)
220
- backport (~> 1.2)
221
- benchmark
222
- bundler (~> 2.0)
223
- diff-lcs (~> 1.4)
224
- e2mmap
225
- jaro_winkler (~> 1.5)
226
- kramdown (~> 2.3)
227
- kramdown-parser-gfm (~> 1.1)
228
- parser (~> 3.0)
229
- rbs (~> 2.0)
230
- reverse_markdown (~> 2.0)
231
- rubocop (~> 1.38)
232
- thor (~> 1.0)
233
- tilt (~> 2.0)
234
- yard (~> 0.9, >= 0.9.24)
235
- thor (1.3.2)
236
- tilt (2.6.0)
237
- timeout (0.4.3)
238
- tzinfo (2.0.6)
239
- concurrent-ruby (~> 1.0)
240
- unf (0.2.0)
241
- unicode-display_width (2.6.0)
242
- webmock (3.24.0)
243
- addressable (>= 2.8.0)
244
- crack (>= 0.3.2)
245
- hashdiff (>= 0.4.0, < 2.0.0)
246
- webrick (1.9.1)
247
- yard (0.9.37)
248
- zeitwerk (2.6.18)
249
-
250
- PLATFORMS
251
- arm64-darwin-22
252
-
253
- DEPENDENCIES
254
- actionmailer
255
- airborne
256
- appraisal
257
- bundler
258
- debug
259
- profile-viewer
260
- pry-byebug
261
- rake
262
- rspec
263
- rspec-rails
264
- rspec-sidekiq
265
- rubocop
266
- shoulda-matchers
267
- simplecov
268
- simplecov-cobertura
269
- solargraph (~> 0.50.0)
270
- solargraph-rspec!
271
- webmock
272
-
273
- BUNDLED WITH
274
- 2.3.17
@@ -1,26 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "bundler"
7
- gem "debug"
8
- gem "profile-viewer"
9
- gem "pry-byebug"
10
- gem "rake"
11
- gem "rspec"
12
- gem "rubocop"
13
- gem "simplecov"
14
- gem "simplecov-cobertura"
15
- gem "solargraph", "~> 0.51.0"
16
-
17
- group :third_party_plugin_tests do
18
- gem "actionmailer"
19
- gem "airborne"
20
- gem "rspec-rails"
21
- gem "rspec-sidekiq"
22
- gem "shoulda-matchers"
23
- gem "webmock"
24
- end
25
-
26
- gemspec path: "../"