ruby-lsp-shoulda-context 0.4.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +2 -0
- data/Readme.md +7 -1
- data/lib/ruby_lsp/ruby-lsp-shoulda-context/addon.rb +6 -15
- data/lib/ruby_lsp/ruby-lsp-shoulda-context/code_lens.rb +20 -10
- data/lib/ruby_lsp/shoulda_context/version.rb +1 -1
- metadata +31 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 707fc43599111261ba56d4ebaee196e3564af183ef2d4ef17def9950690f87a7
|
4
|
+
data.tar.gz: e73bb4abaaa173b3330c43778d5f50170283482b39012115c49cdaf4e7fb0d0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a753433c5fa49613c9e8b4448b0024fce918585d24409fec7b0a549b9f14904cdd1c9fa24142fd7ca398c4fcbc615f662f63a8aa70cf49706cb1574a93973905
|
7
|
+
data.tar.gz: 01c139a9464613fae85b0b1d9852449ff3a59643cb0002d86490625f4a444942b5497ad6edd46f082fb754daafef04a25a43e31c4d3159b2450c0b4d5bad97d8
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
data/Readme.md
CHANGED
@@ -9,7 +9,7 @@ This gem provides support for [shoulda-context](https://github.com/thoughtbot/sh
|
|
9
9
|
|
10
10
|
Add the gem to the application's Gemfile `:development` group:
|
11
11
|
|
12
|
-
gem 'ruby-lsp-shoulda-context', '~> 0.4.
|
12
|
+
gem 'ruby-lsp-shoulda-context', '~> 0.4.2', require: false
|
13
13
|
|
14
14
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
15
15
|
|
@@ -19,6 +19,12 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
19
19
|
|
20
20
|
Just enjoy the magic of LSP with shoulda context tests!.
|
21
21
|
|
22
|
+
The extension can be enabled or disabled passing the `RUBY_LSP_SHOULDA_CONTEXT=[true|false]` enviroment variable. This enviroment variable is loaded automatially from in a `.env` file with priority
|
23
|
+
|
24
|
+
`.env > .env.development > .env.development.local`
|
25
|
+
|
26
|
+
If not set it defaults to `true`
|
27
|
+
|
22
28
|
## Development
|
23
29
|
|
24
30
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -9,13 +9,13 @@ require_relative "code_lens"
|
|
9
9
|
|
10
10
|
module RubyLsp
|
11
11
|
module ShouldaContext
|
12
|
-
# frozen_string_literal: true
|
13
|
-
|
14
12
|
class Addon < ::RubyLsp::Addon
|
15
13
|
extend T::Sig
|
16
14
|
|
17
|
-
sig { override.params(message_queue: Thread::Queue).void }
|
18
|
-
def activate(message_queue)
|
15
|
+
sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
|
16
|
+
def activate(global_state, message_queue)
|
17
|
+
@message_queue = message_queue
|
18
|
+
@global_state = global_state
|
19
19
|
Dotenv.load(".env.development.local", ".env.development")
|
20
20
|
end
|
21
21
|
|
@@ -27,17 +27,8 @@ module RubyLsp
|
|
27
27
|
"Ruby LSP My Gem"
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
override.params(
|
33
|
-
uri: URI::Generic,
|
34
|
-
emitter: Prism::Dispatcher,
|
35
|
-
).returns(T.nilable(Listener[T::Array[Interface::CodeLens]]))
|
36
|
-
end
|
37
|
-
def create_code_lens_listener(uri, emitter)
|
38
|
-
return unless uri.to_standardized_path&.end_with?("_test.rb") || uri.to_standardized_path&.end_with?("_spec.rb")
|
39
|
-
|
40
|
-
CodeLens.new(uri, emitter)
|
30
|
+
def create_code_lens_listener(response_builder, uri, dispatcher)
|
31
|
+
CodeLens.new(response_builder, uri, dispatcher, @global_state)
|
41
32
|
end
|
42
33
|
end
|
43
34
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module RubyLsp
|
5
5
|
module ShouldaContext
|
6
|
-
class CodeLens
|
6
|
+
class CodeLens
|
7
7
|
extend T::Sig
|
8
8
|
extend T::Generic
|
9
9
|
|
@@ -27,11 +27,19 @@ module RubyLsp
|
|
27
27
|
sig { override.returns(ResponseType) }
|
28
28
|
attr_reader :_response
|
29
29
|
|
30
|
-
sig
|
31
|
-
|
30
|
+
sig do
|
31
|
+
params(
|
32
|
+
response_builder: RubyLsp::ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
|
33
|
+
uri: URI::Generic,
|
34
|
+
dispatcher: Prism::Dispatcher,
|
35
|
+
global_state: RubyLsp::GlobalState,
|
36
|
+
).void
|
37
|
+
end
|
38
|
+
def initialize(response_builder, uri, dispatcher, global_state)
|
39
|
+
@response_builder = response_builder
|
40
|
+
@global_state = global_state
|
32
41
|
return if ENV["RUBY_LSP_SHOULDA_CONTEXT"] == "false"
|
33
42
|
|
34
|
-
@_response = T.let([], ResponseType)
|
35
43
|
# Listener is only initialized if uri.to_standardized_path is valid
|
36
44
|
@path = T.let(T.must(uri.to_standardized_path), String)
|
37
45
|
@class_name = T.let("", String)
|
@@ -41,8 +49,6 @@ module RubyLsp
|
|
41
49
|
dispatcher.register(self, :on_call_node_enter, :on_call_node_leave, :on_class_node_enter, :on_class_node_leave)
|
42
50
|
|
43
51
|
@base_command = BASE_COMMAND
|
44
|
-
|
45
|
-
super(dispatcher)
|
46
52
|
end
|
47
53
|
|
48
54
|
sig { params(node: Prism::CallNode).void }
|
@@ -148,7 +154,7 @@ module RubyLsp
|
|
148
154
|
|
149
155
|
sig { params(node: Prism::Node, name: String, kind: Symbol).void }
|
150
156
|
def add_test_code_lens(node, name:, kind:)
|
151
|
-
return unless
|
157
|
+
return unless are_required_libraries_installed?
|
152
158
|
|
153
159
|
if kind == :class
|
154
160
|
pattern = "#{@class_name}Test"
|
@@ -173,7 +179,7 @@ module RubyLsp
|
|
173
179
|
},
|
174
180
|
]
|
175
181
|
|
176
|
-
@
|
182
|
+
@response_builder << create_code_lens(
|
177
183
|
node,
|
178
184
|
title: "Run",
|
179
185
|
command_name: "rubyLsp.runTest",
|
@@ -181,7 +187,7 @@ module RubyLsp
|
|
181
187
|
data: { type: "test", **grouping_data },
|
182
188
|
)
|
183
189
|
|
184
|
-
@
|
190
|
+
@response_builder << create_code_lens(
|
185
191
|
node,
|
186
192
|
title: "Run In Terminal",
|
187
193
|
command_name: "rubyLsp.runTestInTerminal",
|
@@ -189,7 +195,7 @@ module RubyLsp
|
|
189
195
|
data: { type: "test_in_terminal", **grouping_data },
|
190
196
|
)
|
191
197
|
|
192
|
-
@
|
198
|
+
@response_builder << create_code_lens(
|
193
199
|
node,
|
194
200
|
title: "Debug",
|
195
201
|
command_name: "rubyLsp.debugTest",
|
@@ -197,6 +203,10 @@ module RubyLsp
|
|
197
203
|
data: { type: "debug", **grouping_data },
|
198
204
|
)
|
199
205
|
end
|
206
|
+
|
207
|
+
def are_required_libraries_installed?
|
208
|
+
Bundler.locked_gems.dependencies.keys.include?(REQUIRED_LIBRARY)
|
209
|
+
end
|
200
210
|
end
|
201
211
|
end
|
202
212
|
end
|
metadata
CHANGED
@@ -1,35 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp-shoulda-context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domingo Edwards
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dotenv
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
19
|
+
version: '3.0'
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 3.0.2
|
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: '3.0'
|
27
30
|
- - ">="
|
28
31
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
30
|
-
|
32
|
+
version: 3.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby-lsp
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.16.6
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.16.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.16.6
|
50
|
+
- - ">="
|
31
51
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
52
|
+
version: 0.16.0
|
33
53
|
description: An addon for the Ruby LSP that enables shoulda-context testing
|
34
54
|
email:
|
35
55
|
- domingo.edwards@uc.cl
|
@@ -72,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
92
|
- !ruby/object:Gem::Version
|
73
93
|
version: '0'
|
74
94
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
95
|
+
rubygems_version: 3.4.10
|
76
96
|
signing_key:
|
77
97
|
specification_version: 4
|
78
98
|
summary: Ruby LSP shoulda-context
|