solargraph-rspec 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +9 -4
- data/lib/solargraph/rspec/spec_walker/fake_let_method.rb +12 -9
- data/lib/solargraph/rspec/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b218c57b18c9c34c920dc8085633940b40980109acc0767e3819f2f460af7598
|
4
|
+
data.tar.gz: 8d33d3922c38de08dde380776138fb2eddee93f72aaaee1cd7ae4dce7610ac69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d6afb3098eeaa24b1c169ba6993306b14008837ebfd267c30bfe74788cd5deecb7985d33037984f5ed698d259daf9c698dba19f4eed0e6a346f521f081a2d7a
|
7
|
+
data.tar.gz: 88699cf9f89421e1a0306d37ce912c1a1fc231cd722cc4338ec757efed7ca304791b1c2e3e3271b9cb057efe91f2d3db8fa22c70739b88569a0be59c9b0de229
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Suggest keeping `spec/**/*` in the `exclude` section of `.solargraph.yml` to avoid performance issues (see [commit](https://github.com/lekemula/solargraph-rspec/commit/3f0fc39e59e99bf9430e55c52ecb88650e49315e))
|
13
|
+
- Fix `let` definitions when do/end keywords overlap with body definition
|
14
|
+
```ruby
|
15
|
+
let(:todo) do # "do" keyword overlap
|
16
|
+
{
|
17
|
+
'todo' => 'end' # "end" keyword overlap
|
18
|
+
}
|
19
|
+
end
|
20
|
+
```
|
21
|
+
- Error handling in SpecWalker::FakeLetMethod
|
10
22
|
|
11
23
|
## [0.2.1] - 2024-06-09
|
12
24
|
|
data/README.md
CHANGED
@@ -34,14 +34,19 @@ Or add it to your Gemfile:
|
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
group :development do
|
37
|
-
gem 'solargraph'
|
38
|
-
gem 'solargraph-rspec'
|
37
|
+
gem 'solargraph', require: false
|
38
|
+
gem 'solargraph-rspec', require: false
|
39
39
|
end
|
40
40
|
```
|
41
41
|
|
42
42
|
If you add them to your Gemfile, you'll have to tell your IDE plugin to use bundler to load the right version of solargraph.
|
43
43
|
|
44
|
-
Add `solargraph-rspec` to your `.solargraph.yml`
|
44
|
+
Add `solargraph-rspec` to your `.solargraph.yml` as a plugin.
|
45
|
+
|
46
|
+
> [!CAUTION]
|
47
|
+
> To avoid **performance issues**, please keep the `spec/**/*` directory in **exclude** list in the Solargraph configuration.
|
48
|
+
> That does not actually *exclude* the specs, but rather avoids pre-indexing the specs when Solargraph boots up, and only parses
|
49
|
+
> the specs on demand when opened in the editor, which is what we usually want.
|
45
50
|
|
46
51
|
(if you don't have a `.solargraph.yml` in your project root, you can run `solargraph config` to add one)
|
47
52
|
|
@@ -50,7 +55,7 @@ Add `solargraph-rspec` to your `.solargraph.yml` and remove the `spec` directory
|
|
50
55
|
include:
|
51
56
|
- "**/*.rb"
|
52
57
|
exclude:
|
53
|
-
|
58
|
+
+- spec/**/*
|
54
59
|
- test/**/*
|
55
60
|
- vendor/**/*
|
56
61
|
- ".bundle/**/*"
|
@@ -4,18 +4,18 @@ module Solargraph
|
|
4
4
|
module Rspec
|
5
5
|
class SpecWalker
|
6
6
|
class FakeLetMethod
|
7
|
-
|
8
|
-
|
9
|
-
/{(.*)}/m
|
10
|
-
)
|
7
|
+
MATCH_DO_END = /.*? do(.*)end/m.freeze
|
8
|
+
MATCH_CURLY = /{(.*)}/m.freeze
|
11
9
|
|
12
10
|
# @param block_ast [RubyVM::AbstractSyntaxTree::Node]
|
13
|
-
# @return [RubyVM::AbstractSyntaxTree::Node]
|
11
|
+
# @return [RubyVM::AbstractSyntaxTree::Node, nil]
|
14
12
|
def self.transform_block(block_ast, code, method_name = nil)
|
15
13
|
method_name ||= NodeTypes.let_method_name(block_ast)
|
16
14
|
block_body = block_ast.children[1]
|
17
|
-
|
18
|
-
|
15
|
+
let_definition_code = code.lines[block_body.first_lineno - 1..block_body.last_lineno - 1].join
|
16
|
+
match_do_end = let_definition_code.match(MATCH_DO_END)&.captures&.first || ''
|
17
|
+
match_curly = let_definition_code.match(MATCH_CURLY)&.captures&.first || ''
|
18
|
+
method_body = [match_do_end, match_curly].max_by(&:length).strip
|
19
19
|
|
20
20
|
ast = RubyVM::AbstractSyntaxTree.parse <<~RUBY
|
21
21
|
def #{method_name}
|
@@ -24,8 +24,11 @@ module Solargraph
|
|
24
24
|
RUBY
|
25
25
|
|
26
26
|
ast.children[2]
|
27
|
-
rescue SyntaxError
|
28
|
-
|
27
|
+
rescue SyntaxError => e
|
28
|
+
Solargraph.logger.warn "[RSpec] Failed to build fake let method: #{e.message}, \
|
29
|
+
\n\nlet_definition_code: \n```\n#{let_definition_code}\n```, \
|
30
|
+
\n\nmethod_body: \n```\n#{method_body}\n```, \
|
31
|
+
\nast: #{block_ast.inspect}"
|
29
32
|
ensure
|
30
33
|
nil
|
31
34
|
end
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lekë Mula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-23 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:
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
92
|
+
rubygems_version: 3.4.10
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Solargraph plugin supporting RSpec code completion
|