solargraph-rspec 0.3.0 β 0.4.1
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/.rubocop.yml +10 -0
- data/Appraisals +9 -0
- data/CHANGELOG.md +25 -1
- data/README.md +17 -10
- data/doc/images/3rd_party_matchers.png +0 -0
- data/doc/images/one_liners_demo.gif +0 -0
- data/doc/images/vim_demo.gif +0 -0
- data/doc/images/vscode_demo.gif +0 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/solargraph_0.50.gemfile +26 -0
- data/gemfiles/solargraph_0.50.gemfile.lock +274 -0
- data/gemfiles/solargraph_0.51.gemfile +26 -0
- data/gemfiles/solargraph_0.51.gemfile.lock +277 -0
- data/lib/solargraph/rspec/annotations.rb +7 -0
- data/lib/solargraph/rspec/convention.rb +22 -19
- data/lib/solargraph/rspec/correctors/subject_method_corrector.rb +42 -2
- data/lib/solargraph/rspec/spec_walker/fake_let_method.rb +63 -19
- data/lib/solargraph/rspec/spec_walker.rb +15 -2
- data/lib/solargraph/rspec/test_helpers.rb +93 -0
- data/lib/solargraph/rspec/version.rb +1 -1
- data/lib/solargraph-rspec.rb +0 -8
- metadata +21 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5246aadadd47bc9c4a53acbd1841f08187385c89b1a9a64bbb13d7d602f1522a
|
4
|
+
data.tar.gz: b1b8dac88f82644833f309e0e2816d1950fd69ccef0b1a52093305bf6f61a08c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 828b1fdd6923a9621fcbee693d32048e1625feed89b47d2a7ce9931fbe9ee6a2fa58f4fb6bc2a3558955ce422da86ba1c940fa028c01a9f3cee9032b8f6737cb
|
7
|
+
data.tar.gz: fd447792d52866c3e47bd0700d48630a390fcfe347d8f3e682a9c9dd29dd9c8f95e05a1ec02ecfba802a4883cb071f8c3db038d33fec7bb2f98913d235e282aa
|
data/.rubocop.yml
CHANGED
@@ -5,6 +5,13 @@ AllCops:
|
|
5
5
|
Style/StringLiterals:
|
6
6
|
Enabled: true
|
7
7
|
EnforcedStyle: single_quotes
|
8
|
+
Exclude:
|
9
|
+
- "gemfiles/**/*"
|
10
|
+
|
11
|
+
Style/FrozenStringLiteralComment:
|
12
|
+
Enabled: true
|
13
|
+
Exclude:
|
14
|
+
- "gemfiles/**/*"
|
8
15
|
|
9
16
|
Style/StringLiteralsInInterpolation:
|
10
17
|
Enabled: true
|
@@ -13,6 +20,9 @@ Style/StringLiteralsInInterpolation:
|
|
13
20
|
Style/Documentation:
|
14
21
|
Enabled: false
|
15
22
|
|
23
|
+
Style/StructInheritance:
|
24
|
+
Enabled: false
|
25
|
+
|
16
26
|
Layout/LineLength:
|
17
27
|
Max: 120
|
18
28
|
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -7,7 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
-
|
10
|
+
## v.0.4.1 - 2025-01-28
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- (Hot)fix parsing and type inference for solargraph v0.51.x and ruby v3.4.x (008d3ea and 414bc8e)
|
15
|
+
|
16
|
+
## v.0.4.0 - 2024-08-25
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- Support for 3rd party helpers from most known RSpec extension libraries.
|
21
|
+
- [rspec-mocks](https://github.com/rspec/rspec-mocks)
|
22
|
+
- [rspec-rails](https://github.com/rspec/rspec-rails)
|
23
|
+
- [webmock](https://github.com/bblimke/webmock)
|
24
|
+
- [shoulda-matchers](https://matchers.shoulda.io/)
|
25
|
+
- [rspec-sidekiq](https://github.com/wspurgin/rspec-sidekiq)
|
26
|
+
- [airborne](https://github.com/brooklynDev/airborne)
|
27
|
+
- <details><summary>πΈ</summary>
|
28
|
+
<img src="./doc/images/3rd_party_matchers.png" width="600" alt="3rd party matchers completion">
|
29
|
+
</details>
|
30
|
+
|
31
|
+
- Implement RSpec [one-liner syntax](https://rspec.info/features/3-12/rspec-core/subject/one-liner-syntax/) helpers: `is_expected`, `should` and `should_not`
|
32
|
+
- <details><summary>πΉ</summary>
|
33
|
+
<img src="./doc/images/one_liners_demo.gif" width="600" alt="One-liner syntax completion">
|
34
|
+
</details>
|
11
35
|
|
12
36
|
## v0.3.0 - 2024-07-10
|
13
37
|
|
data/README.md
CHANGED
@@ -7,17 +7,24 @@
|
|
7
7
|
|
8
8
|
RSpec is a testing framework of choice for many Ruby developers. But at the same time is highly dynamic and heavily relying on metaprogramming making it hard to provide accurate code completion and type inference.
|
9
9
|
|
10
|
-
This gem aims to provide better support for RSpec in Solargraph and it supports the following features:
|
11
|
-
- `describe` and `it` methods
|
12
|
-
- memoized `let` and `let!` methods
|
13
|
-
- implicit and explicit `subject` methods
|
10
|
+
This gem aims to provide better support for RSpec in Solargraph and it supports the following features (completion, jump to definition and type inference π):
|
11
|
+
- `describe` and `it` methods
|
12
|
+
- memoized `let` and `let!` methods
|
14
13
|
- `described_class` with appropriate type inference
|
15
|
-
- `
|
16
|
-
-
|
17
|
-
- and
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
- implicit and explicit `subject` methods
|
15
|
+
- one liner syntax helpers `is_expected`, `should` and `should_not` linked to the appropriate subject
|
16
|
+
- Core and 3rd party spec helpers & matchers
|
17
|
+
- [rspec-mocks](https://github.com/rspec/rspec-mocks)
|
18
|
+
- [rspec-rails](https://github.com/rspec/rspec-rails)
|
19
|
+
- [webmock](https://github.com/bblimke/webmock)
|
20
|
+
- [shoulda-matchers](https://matchers.shoulda.io/)
|
21
|
+
- [rspec-sidekiq](https://github.com/wspurgin/rspec-sidekiq)
|
22
|
+
- [airborne](https://github.com/brooklynDev/airborne)
|
23
|
+
- Custom DSL extensions support (see [Configuration](#configuration) section)
|
24
|
+
- and more to come... β²οΈ
|
25
|
+
|
26
|
+

|
27
|
+

|
21
28
|
|
22
29
|
|
23
30
|
## Installation
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
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.50.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: "../"
|
@@ -0,0 +1,274 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
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: "../"
|
@@ -0,0 +1,277 @@
|
|
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
|
+
erubi (1.13.1)
|
73
|
+
globalid (1.2.1)
|
74
|
+
activesupport (>= 6.1)
|
75
|
+
hashdiff (1.1.2)
|
76
|
+
http-accept (1.7.0)
|
77
|
+
http-cookie (1.0.8)
|
78
|
+
domain_name (~> 0.5)
|
79
|
+
i18n (1.14.7)
|
80
|
+
concurrent-ruby (~> 1.0)
|
81
|
+
io-console (0.8.0)
|
82
|
+
irb (1.6.3)
|
83
|
+
reline (>= 0.3.0)
|
84
|
+
jaro_winkler (1.6.0)
|
85
|
+
json (2.7.6)
|
86
|
+
kramdown (2.5.1)
|
87
|
+
rexml (>= 3.3.9)
|
88
|
+
kramdown-parser-gfm (1.1.0)
|
89
|
+
kramdown (~> 2.0)
|
90
|
+
logger (1.6.5)
|
91
|
+
loofah (2.24.0)
|
92
|
+
crass (~> 1.0.2)
|
93
|
+
nokogiri (>= 1.12.0)
|
94
|
+
mail (2.8.1)
|
95
|
+
mini_mime (>= 0.1.1)
|
96
|
+
net-imap
|
97
|
+
net-pop
|
98
|
+
net-smtp
|
99
|
+
method_source (1.1.0)
|
100
|
+
mime-types (3.6.0)
|
101
|
+
logger
|
102
|
+
mime-types-data (~> 3.2015)
|
103
|
+
mime-types-data (3.2025.0107)
|
104
|
+
mini_mime (1.1.5)
|
105
|
+
minitest (5.25.4)
|
106
|
+
net-imap (0.3.7)
|
107
|
+
date
|
108
|
+
net-protocol
|
109
|
+
net-pop (0.1.2)
|
110
|
+
net-protocol
|
111
|
+
net-protocol (0.2.2)
|
112
|
+
timeout
|
113
|
+
net-smtp (0.5.0)
|
114
|
+
net-protocol
|
115
|
+
netrc (0.11.0)
|
116
|
+
nokogiri (1.13.10-arm64-darwin)
|
117
|
+
racc (~> 1.4)
|
118
|
+
observer (0.1.2)
|
119
|
+
optparse (0.6.0)
|
120
|
+
ostruct (0.6.1)
|
121
|
+
parallel (1.24.0)
|
122
|
+
parser (3.3.7.0)
|
123
|
+
ast (~> 2.4.1)
|
124
|
+
racc
|
125
|
+
profile-viewer (0.0.4)
|
126
|
+
optparse
|
127
|
+
webrick
|
128
|
+
pry (0.13.1)
|
129
|
+
coderay (~> 1.1)
|
130
|
+
method_source (~> 1.0)
|
131
|
+
pry-byebug (3.9.0)
|
132
|
+
byebug (~> 11.0)
|
133
|
+
pry (~> 0.13.0)
|
134
|
+
public_suffix (5.1.1)
|
135
|
+
racc (1.8.1)
|
136
|
+
rack (2.2.10)
|
137
|
+
rack-test (1.1.0)
|
138
|
+
rack (>= 1.0, < 3)
|
139
|
+
rails-dom-testing (2.2.0)
|
140
|
+
activesupport (>= 5.0.0)
|
141
|
+
minitest
|
142
|
+
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
|
149
|
+
rake (>= 12.2)
|
150
|
+
thor (~> 1.0)
|
151
|
+
rainbow (3.1.1)
|
152
|
+
rake (13.2.1)
|
153
|
+
rbs (3.1.3)
|
154
|
+
redis (4.8.1)
|
155
|
+
regexp_parser (2.10.0)
|
156
|
+
reline (0.6.0)
|
157
|
+
io-console (~> 0.5)
|
158
|
+
rest-client (2.1.0)
|
159
|
+
http-accept (>= 1.7.0, < 2.0)
|
160
|
+
http-cookie (>= 1.0.2, < 2.0)
|
161
|
+
mime-types (>= 1.16, < 4.0)
|
162
|
+
netrc (~> 0.8)
|
163
|
+
reverse_markdown (3.0.0)
|
164
|
+
nokogiri
|
165
|
+
rexml (3.4.0)
|
166
|
+
rspec (3.13.0)
|
167
|
+
rspec-core (~> 3.13.0)
|
168
|
+
rspec-expectations (~> 3.13.0)
|
169
|
+
rspec-mocks (~> 3.13.0)
|
170
|
+
rspec-core (3.13.2)
|
171
|
+
rspec-support (~> 3.13.0)
|
172
|
+
rspec-expectations (3.13.3)
|
173
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
174
|
+
rspec-support (~> 3.13.0)
|
175
|
+
rspec-mocks (3.13.2)
|
176
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
177
|
+
rspec-support (~> 3.13.0)
|
178
|
+
rspec-rails (6.1.5)
|
179
|
+
actionpack (>= 6.1)
|
180
|
+
activesupport (>= 6.1)
|
181
|
+
railties (>= 6.1)
|
182
|
+
rspec-core (~> 3.13)
|
183
|
+
rspec-expectations (~> 3.13)
|
184
|
+
rspec-mocks (~> 3.13)
|
185
|
+
rspec-support (~> 3.13)
|
186
|
+
rspec-sidekiq (4.0.2)
|
187
|
+
rspec-core (~> 3.0)
|
188
|
+
rspec-expectations (~> 3.0)
|
189
|
+
rspec-mocks (~> 3.0)
|
190
|
+
sidekiq (>= 5, < 8)
|
191
|
+
rspec-support (3.13.2)
|
192
|
+
rubocop (1.50.2)
|
193
|
+
json (~> 2.3)
|
194
|
+
parallel (~> 1.10)
|
195
|
+
parser (>= 3.2.0.0)
|
196
|
+
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)
|
200
|
+
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)
|
204
|
+
ruby-progressbar (1.13.0)
|
205
|
+
shoulda-matchers (5.3.0)
|
206
|
+
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)
|
211
|
+
simplecov (0.22.0)
|
212
|
+
docile (~> 1.1)
|
213
|
+
simplecov-html (~> 0.11)
|
214
|
+
simplecov_json_formatter (~> 0.1)
|
215
|
+
simplecov-cobertura (2.1.0)
|
216
|
+
rexml
|
217
|
+
simplecov (~> 0.19)
|
218
|
+
simplecov-html (0.13.1)
|
219
|
+
simplecov_json_formatter (0.1.4)
|
220
|
+
solargraph (0.51.1)
|
221
|
+
backport (~> 1.2)
|
222
|
+
benchmark
|
223
|
+
bundler (~> 2.0)
|
224
|
+
diff-lcs (~> 1.4)
|
225
|
+
jaro_winkler (~> 1.6)
|
226
|
+
kramdown (~> 2.3)
|
227
|
+
kramdown-parser-gfm (~> 1.1)
|
228
|
+
logger (~> 1.6)
|
229
|
+
observer (~> 0.1)
|
230
|
+
ostruct (~> 0.6)
|
231
|
+
parser (~> 3.0)
|
232
|
+
rbs (~> 3.0)
|
233
|
+
reverse_markdown (>= 2.0, < 4)
|
234
|
+
rubocop (~> 1.38)
|
235
|
+
thor (~> 1.0)
|
236
|
+
tilt (~> 2.0)
|
237
|
+
yard (~> 0.9, >= 0.9.24)
|
238
|
+
thor (1.3.2)
|
239
|
+
tilt (2.6.0)
|
240
|
+
timeout (0.4.3)
|
241
|
+
tzinfo (2.0.6)
|
242
|
+
concurrent-ruby (~> 1.0)
|
243
|
+
unf (0.2.0)
|
244
|
+
unicode-display_width (2.6.0)
|
245
|
+
webmock (3.24.0)
|
246
|
+
addressable (>= 2.8.0)
|
247
|
+
crack (>= 0.3.2)
|
248
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
249
|
+
webrick (1.9.1)
|
250
|
+
yard (0.9.37)
|
251
|
+
zeitwerk (2.6.18)
|
252
|
+
|
253
|
+
PLATFORMS
|
254
|
+
arm64-darwin-22
|
255
|
+
|
256
|
+
DEPENDENCIES
|
257
|
+
actionmailer
|
258
|
+
airborne
|
259
|
+
appraisal
|
260
|
+
bundler
|
261
|
+
debug
|
262
|
+
profile-viewer
|
263
|
+
pry-byebug
|
264
|
+
rake
|
265
|
+
rspec
|
266
|
+
rspec-rails
|
267
|
+
rspec-sidekiq
|
268
|
+
rubocop
|
269
|
+
shoulda-matchers
|
270
|
+
simplecov
|
271
|
+
simplecov-cobertura
|
272
|
+
solargraph (~> 0.51.0)
|
273
|
+
solargraph-rspec!
|
274
|
+
webmock
|
275
|
+
|
276
|
+
BUNDLED WITH
|
277
|
+
2.3.17
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'config'
|
4
4
|
require_relative 'spec_walker'
|
5
|
+
require_relative 'annotations'
|
5
6
|
require_relative 'correctors/context_block_namespace_corrector'
|
6
7
|
require_relative 'correctors/example_and_hook_blocks_binding_corrector'
|
7
8
|
require_relative 'correctors/described_class_corrector'
|
@@ -9,12 +10,12 @@ require_relative 'correctors/let_methods_corrector'
|
|
9
10
|
require_relative 'correctors/subject_method_corrector'
|
10
11
|
require_relative 'correctors/context_block_methods_corrector'
|
11
12
|
require_relative 'correctors/dsl_methods_corrector'
|
13
|
+
require_relative 'test_helpers'
|
12
14
|
require_relative 'pin_factory'
|
13
15
|
|
14
16
|
module Solargraph
|
15
17
|
module Rspec
|
16
18
|
ROOT_NAMESPACE = 'RSpec::ExampleGroups'
|
17
|
-
HELPER_MODULES = ['RSpec::Matchers'].freeze
|
18
19
|
HOOK_METHODS = %w[before after around].freeze
|
19
20
|
LET_METHODS = %w[let let!].freeze
|
20
21
|
SUBJECT_METHODS = %w[subject subject!].freeze
|
@@ -83,7 +84,12 @@ module Solargraph
|
|
83
84
|
# @return [Environ]
|
84
85
|
def global(_yard_map)
|
85
86
|
pins = []
|
86
|
-
pins += include_helper_pins
|
87
|
+
pins += Solargraph::Rspec::TestHelpers.include_helper_pins(
|
88
|
+
root_example_group_namespace_pin: root_example_group_namespace_pin
|
89
|
+
)
|
90
|
+
pins += annotation_pins
|
91
|
+
# TODO: Include gem requires conditionally based on Gemfile definition
|
92
|
+
requires = Solargraph::Rspec::TestHelpers.gem_names
|
87
93
|
|
88
94
|
if pins.any?
|
89
95
|
Solargraph.logger.debug(
|
@@ -91,8 +97,10 @@ module Solargraph
|
|
91
97
|
)
|
92
98
|
end
|
93
99
|
|
94
|
-
|
95
|
-
|
100
|
+
Solargraph.logger.debug "[RSpec] added requires #{requires}"
|
101
|
+
|
102
|
+
Environ.new(requires: requires, pins: pins)
|
103
|
+
rescue StandardError, SyntaxError => e
|
96
104
|
raise e if ENV['SOLARGRAPH_DEBUG']
|
97
105
|
|
98
106
|
Solargraph.logger.warn(
|
@@ -132,8 +140,8 @@ module Solargraph
|
|
132
140
|
)
|
133
141
|
end
|
134
142
|
|
135
|
-
Environ.new(requires: [
|
136
|
-
rescue StandardError => e
|
143
|
+
Environ.new(requires: [], pins: pins)
|
144
|
+
rescue StandardError, SyntaxError => e
|
137
145
|
raise e if ENV['SOLARGRAPH_DEBUG']
|
138
146
|
|
139
147
|
Solargraph.logger.warn(
|
@@ -144,19 +152,6 @@ module Solargraph
|
|
144
152
|
|
145
153
|
private
|
146
154
|
|
147
|
-
# @param helper_modules [Array<String>]
|
148
|
-
# @param source_map [SourceMap]
|
149
|
-
# @return [Array<Pin::Base>]
|
150
|
-
def include_helper_pins(helper_modules: HELPER_MODULES)
|
151
|
-
helper_modules.map do |helper_module|
|
152
|
-
PinFactory.build_module_include(
|
153
|
-
root_example_group_namespace_pin,
|
154
|
-
helper_module,
|
155
|
-
root_example_group_namespace_pin.location
|
156
|
-
)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
155
|
# @return [Config]
|
161
156
|
def config
|
162
157
|
self.class.config
|
@@ -169,6 +164,14 @@ module Solargraph
|
|
169
164
|
location: PinFactory.dummy_location('lib/rspec/core/example_group.rb')
|
170
165
|
)
|
171
166
|
end
|
167
|
+
|
168
|
+
# @return [Array<Pin::Base>]
|
169
|
+
def annotation_pins
|
170
|
+
ann = File.read("#{File.dirname(__FILE__)}/annotations.rb")
|
171
|
+
source = Solargraph::Source.load_string(ann, 'rspec-annotations.rb')
|
172
|
+
map = Solargraph::SourceMap.map(source)
|
173
|
+
map.pins
|
174
|
+
end
|
172
175
|
end
|
173
176
|
end
|
174
177
|
end
|
@@ -16,6 +16,7 @@ module Solargraph
|
|
16
16
|
|
17
17
|
subject_pin = rspec_subject_method(namespace_pin, subject_name, location_range, fake_method_ast)
|
18
18
|
add_pin(subject_pin)
|
19
|
+
add_pins(one_liner_expectation_pins(subject_pin))
|
19
20
|
end
|
20
21
|
|
21
22
|
rspec_walker.after_walk do
|
@@ -23,7 +24,11 @@ module Solargraph
|
|
23
24
|
|
24
25
|
namespace_pin = closest_namespace_pin(namespace_pins, described_class_pin.location.range.start.line)
|
25
26
|
|
26
|
-
|
27
|
+
if namespace_pin
|
28
|
+
implicit_subject_pin = implicit_subject_method(described_class_pin, namespace_pin)
|
29
|
+
add_pin(implicit_subject_pin)
|
30
|
+
add_pins(one_liner_expectation_pins(implicit_subject_pin))
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
@@ -47,7 +52,7 @@ module Solargraph
|
|
47
52
|
# @param described_class_pin [Pin::Method]
|
48
53
|
# @param namespace_pin [Pin::Namespace]
|
49
54
|
# @return [Pin::Method]
|
50
|
-
def
|
55
|
+
def implicit_subject_method(described_class_pin, namespace_pin)
|
51
56
|
described_class = described_class_pin.return_type.first.subtypes.first.name
|
52
57
|
|
53
58
|
PinFactory.build_public_method(
|
@@ -58,6 +63,41 @@ module Solargraph
|
|
58
63
|
scope: :instance
|
59
64
|
)
|
60
65
|
end
|
66
|
+
|
67
|
+
# @param subject_pin [Pin::Method]
|
68
|
+
# @return [Array<Pin::Method>]
|
69
|
+
def one_liner_expectation_pins(subject_pin)
|
70
|
+
[
|
71
|
+
one_liner_expectation_pin(subject_pin.closure, :is_expected, subject_pin.location),
|
72
|
+
one_liner_expectation_pin(subject_pin.closure, :should, subject_pin.location),
|
73
|
+
one_liner_expectation_pin(subject_pin.closure, :should_not, subject_pin.location)
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param namespace_pin [Pin::Namespace]
|
78
|
+
# @param method_name [:is_expected, :should, :should_not]
|
79
|
+
# @param location [Solargraph::Location]
|
80
|
+
# @return [Pin::Method]
|
81
|
+
def one_liner_expectation_pin(namespace_pin, method_name, location)
|
82
|
+
return_type = case method_name
|
83
|
+
when :is_expected
|
84
|
+
['::RSpec::Expectations::ExpectationTarget']
|
85
|
+
when :should
|
86
|
+
['::RSpec::Matchers::BuiltIn::PositiveOperatorMatcher']
|
87
|
+
when :should_not
|
88
|
+
['::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher']
|
89
|
+
else
|
90
|
+
raise ArgumentError, "Unknown inline expectation method: #{method_name}"
|
91
|
+
end
|
92
|
+
|
93
|
+
PinFactory.build_public_method(
|
94
|
+
namespace_pin,
|
95
|
+
method_name.to_s,
|
96
|
+
types: [return_type],
|
97
|
+
location: location,
|
98
|
+
scope: :instance
|
99
|
+
)
|
100
|
+
end
|
61
101
|
end
|
62
102
|
end
|
63
103
|
end
|
@@ -7,30 +7,74 @@ module Solargraph
|
|
7
7
|
MATCH_DO_END = /.*? do(.*)end/m.freeze
|
8
8
|
MATCH_CURLY = /{(.*)}/m.freeze
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def #{method_name}
|
22
|
-
#{method_body}
|
10
|
+
class << self
|
11
|
+
# Transforms let block to method ast node
|
12
|
+
# @param block_ast [RubyVM::AbstractSyntaxTree::Node]
|
13
|
+
# @return [RubyVM::AbstractSyntaxTree::Node, ::Parser::AST::Node, nil]
|
14
|
+
def transform_block(block_ast, code, method_name = nil)
|
15
|
+
method_name ||= NodeTypes.let_method_name(block_ast)
|
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)
|
23
21
|
end
|
24
|
-
|
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
|
+
code_lines = code.split("\n")
|
53
|
+
# extract let definition block body code
|
54
|
+
first_line = code_lines[block_ast.first_lineno - 1]
|
55
|
+
last_line = code_lines[block_ast.last_lineno - 1]
|
56
|
+
code_lines[block_ast.first_lineno - 1] = first_line[(block_ast.first_column)..]
|
57
|
+
code_lines[block_ast.last_lineno - 1] = last_line[0..(block_ast.last_column)]
|
58
|
+
let_definition_code = code_lines[
|
59
|
+
(block_ast.first_lineno - 1)..(block_ast.last_lineno - 1)
|
60
|
+
].join("\n")
|
25
61
|
|
26
|
-
|
27
|
-
|
28
|
-
|
62
|
+
let_definition_ast = ::Parser::CurrentRuby.parse(let_definition_code)
|
63
|
+
method_body = let_definition_ast.children[2]
|
64
|
+
::Parser::AST::Node.new( # transform let block to a method ast node
|
65
|
+
:def,
|
66
|
+
[
|
67
|
+
method_name.to_sym,
|
68
|
+
::Parser::AST::Node.new(:args, []),
|
69
|
+
method_body
|
70
|
+
]
|
71
|
+
)
|
72
|
+
rescue SyntaxError => e
|
73
|
+
Solargraph.logger.warn "[RSpec] Failed to build fake let method: #{e.message}, \
|
29
74
|
\n\nlet_definition_code: \n```\n#{let_definition_code}\n```, \
|
30
75
|
\n\nmethod_body: \n```\n#{method_body}\n```, \
|
31
76
|
\nast: #{block_ast.inspect}"
|
32
|
-
|
33
|
-
nil
|
77
|
+
end
|
34
78
|
end
|
35
79
|
end
|
36
80
|
end
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
14
14
|
def initialize(source_map:, config:)
|
15
15
|
@source_map = source_map
|
16
16
|
@config = config
|
17
|
-
@walker = Rspec::Walker.new(source_map
|
17
|
+
@walker = Rspec::Walker.new(ruby_vm_node(source_map))
|
18
18
|
@handlers = {
|
19
19
|
on_described_class: [],
|
20
20
|
on_let_method: [],
|
@@ -119,7 +119,7 @@ module Solargraph
|
|
119
119
|
method_name = NodeTypes.let_method_name(block_ast)
|
120
120
|
next unless method_name
|
121
121
|
|
122
|
-
fake_method_ast = FakeLetMethod.transform_block(block_ast, @source_map.source.code)
|
122
|
+
fake_method_ast = FakeLetMethod.transform_block(block_ast, @source_map.source.code, method_name)
|
123
123
|
|
124
124
|
@handlers[:on_let_method].each do |handler|
|
125
125
|
handler.call(method_name, PinFactory.build_location_range(block_ast.children[0]), fake_method_ast)
|
@@ -210,6 +210,19 @@ module Solargraph
|
|
210
210
|
next parent_namespace
|
211
211
|
end
|
212
212
|
end
|
213
|
+
|
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
|
+
# @param source_map [SourceMap]
|
218
|
+
# @return [RubyVM::AbstractSyntaxTree::Node]
|
219
|
+
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
|
225
|
+
end
|
213
226
|
end
|
214
227
|
end
|
215
228
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Rspec
|
5
|
+
class TestHelpers
|
6
|
+
class GemHelpers < Struct.new(:required_gems, :helper_modules, keyword_init: true)
|
7
|
+
# @!attribute [r] required_gems
|
8
|
+
# @return [Array<String>]
|
9
|
+
# @!attribute [r] helper_modules
|
10
|
+
# @return [Array<String>]
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
# @return [String]
|
15
|
+
def gem_names
|
16
|
+
GEM_HELPERS.flat_map(&:required_gems)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Array<String>]
|
20
|
+
def helper_module_names
|
21
|
+
GEM_HELPERS.flat_map(&:helper_modules)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param root_example_group_namespace_pin [Pin::Namespace]
|
25
|
+
# @return [Array<Pin::Reference::Include>]
|
26
|
+
def include_helper_pins(root_example_group_namespace_pin:)
|
27
|
+
Solargraph.logger.debug "[RSpec] adding helper modules #{helper_module_names}"
|
28
|
+
helper_module_names.map do |helper_module|
|
29
|
+
PinFactory.build_module_include(
|
30
|
+
root_example_group_namespace_pin,
|
31
|
+
helper_module,
|
32
|
+
root_example_group_namespace_pin.location
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
GEM_HELPERS = [
|
39
|
+
GemHelpers.new(
|
40
|
+
required_gems: %w[rspec],
|
41
|
+
helper_modules: %w[RSpec::Matchers]
|
42
|
+
),
|
43
|
+
# https://github.com/rspec/rspec-mocks
|
44
|
+
GemHelpers.new(
|
45
|
+
required_gems: %w[rspec-mocks],
|
46
|
+
helper_modules: %w[RSpec::Mocks::ExampleMethods]
|
47
|
+
),
|
48
|
+
# @see https://github.com/rspec/rspec-rails#what-tests-should-i-write
|
49
|
+
# @see https://github.com/rspec/rspec-rails#helpful-rails-matchers
|
50
|
+
GemHelpers.new(
|
51
|
+
required_gems: %w[rspec-rails actionmailer activesupport activerecord],
|
52
|
+
helper_modules: [
|
53
|
+
'RSpec::Rails::Matchers',
|
54
|
+
'ActionController::TestCase::Behavior',
|
55
|
+
'ActionMailer::TestCase::Behavior',
|
56
|
+
'ActiveSupport::Testing::Assertions',
|
57
|
+
'ActiveSupport::Testing::TimeHelpers',
|
58
|
+
'ActiveSupport::Testing::FileFixtures',
|
59
|
+
'ActiveRecord::TestFixtures',
|
60
|
+
'ActionDispatch::Integration::Runner',
|
61
|
+
'ActionDispatch::Routing::UrlFor',
|
62
|
+
'ActionController::TemplateAssertions'
|
63
|
+
]
|
64
|
+
),
|
65
|
+
# @see https://matchers.shoulda.io/docs/v6.2.0/#matchers
|
66
|
+
GemHelpers.new(
|
67
|
+
required_gems: %w[shoulda-matchers],
|
68
|
+
helper_modules: [
|
69
|
+
'Shoulda::Matchers::ActiveModel',
|
70
|
+
'Shoulda::Matchers::ActiveRecord',
|
71
|
+
'Shoulda::Matchers::ActionController',
|
72
|
+
'Shoulda::Matchers::Routing'
|
73
|
+
]
|
74
|
+
),
|
75
|
+
# @see https://github.com/wspurgin/rspec-sidekiq#matchers
|
76
|
+
GemHelpers.new(
|
77
|
+
required_gems: %w[rspec-sidekiq],
|
78
|
+
helper_modules: %w[RSpec::Sidekiq::Matchers]
|
79
|
+
),
|
80
|
+
# @see https://github.com/bblimke/webmock#examples
|
81
|
+
GemHelpers.new(
|
82
|
+
required_gems: %w[webmock],
|
83
|
+
helper_modules: %w[WebMock::API WebMock::Matchers]
|
84
|
+
),
|
85
|
+
# @see https://github.com/brooklynDev/airborne
|
86
|
+
GemHelpers.new(
|
87
|
+
required_gems: %w[airborne],
|
88
|
+
helper_modules: %w[Airborne]
|
89
|
+
)
|
90
|
+
].freeze
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/solargraph-rspec.rb
CHANGED
@@ -6,13 +6,5 @@ require 'solargraph'
|
|
6
6
|
require_relative 'solargraph/rspec/version'
|
7
7
|
require_relative 'solargraph/rspec/convention'
|
8
8
|
|
9
|
-
module Solargraph
|
10
|
-
module Rspec
|
11
|
-
class NodeParser
|
12
|
-
extend Solargraph::Parser::Legacy::ClassMethods
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
Solargraph::Convention.register Solargraph::Rspec::Convention
|
18
10
|
# rubocop:enable Naming/FileName
|
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LekΓ« Mula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solargraph
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.49.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '0.49'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.49.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.49.0
|
30
27
|
- - "~>"
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '0.49'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.49.0
|
33
33
|
description: RSpec is a testing tool of choice for many Ruby developers. This plugin
|
34
34
|
provides code completion and other features for RSpec files in Solargraph.
|
35
35
|
email:
|
@@ -40,13 +40,24 @@ extra_rdoc_files: []
|
|
40
40
|
files:
|
41
41
|
- ".rspec"
|
42
42
|
- ".rubocop.yml"
|
43
|
+
- Appraisals
|
43
44
|
- CHANGELOG.md
|
44
45
|
- CODE_OF_CONDUCT.md
|
45
46
|
- LICENSE.txt
|
46
47
|
- README.md
|
47
48
|
- Rakefile
|
48
49
|
- codecov.yml
|
50
|
+
- doc/images/3rd_party_matchers.png
|
51
|
+
- doc/images/one_liners_demo.gif
|
52
|
+
- doc/images/vim_demo.gif
|
53
|
+
- doc/images/vscode_demo.gif
|
54
|
+
- 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
|
49
59
|
- lib/solargraph-rspec.rb
|
60
|
+
- lib/solargraph/rspec/annotations.rb
|
50
61
|
- lib/solargraph/rspec/config.rb
|
51
62
|
- lib/solargraph/rspec/convention.rb
|
52
63
|
- lib/solargraph/rspec/correctors/base.rb
|
@@ -63,6 +74,7 @@ files:
|
|
63
74
|
- lib/solargraph/rspec/spec_walker/full_constant_name.rb
|
64
75
|
- lib/solargraph/rspec/spec_walker/node_types.rb
|
65
76
|
- lib/solargraph/rspec/spec_walker/rspec_context_namespace.rb
|
77
|
+
- lib/solargraph/rspec/test_helpers.rb
|
66
78
|
- lib/solargraph/rspec/version.rb
|
67
79
|
- lib/solargraph/rspec/walker.rb
|
68
80
|
- lib/solargraph_rspec.rb
|
@@ -89,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
101
|
- !ruby/object:Gem::Version
|
90
102
|
version: '0'
|
91
103
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.2.3
|
93
105
|
signing_key:
|
94
106
|
specification_version: 4
|
95
107
|
summary: Solargraph plugin supporting RSpec code completion
|