ruby-lsp-shoulda-context 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.development +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/Readme.md +12 -5
- data/lib/ruby_lsp/ruby-lsp-shoulda-context/addon.rb +9 -15
- data/lib/ruby_lsp/ruby-lsp-shoulda-context/code_lens.rb +22 -10
- data/lib/ruby_lsp/shoulda_context/version.rb +1 -1
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 567715719f531b65148d1045d77587e2541367cff87d1725f637d89a3044d850
|
4
|
+
data.tar.gz: 6961db9e727610bb2290389de35892142e5f9d3c8828fa02f077d7de6f48176e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44194a81d42a9bdfa82ad4afca221d2449ad06bb9521b23cea37a8c832baa1ed11fe8ec7f46998b85f15644852c5d55b325a3c291f20d3535fc3692300bee581
|
7
|
+
data.tar.gz: 78b0f20fa728fadab0bb716dea23c6e91d0788f67c34f1b43bd72b45c2c1ed2b1b68820f47fdaf716b93e227ddd02f2c47635f365259246d12f24a2a07587700
|
data/.env.development
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
RUBY_LSP_SHOULDA_CONTEXT=true
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
## [Unreleased]
|
2
|
+
## [0.4.0] - 2024-02-10
|
3
|
+
- Added support to ruby on rails
|
4
|
+
- Fixed Class Run on terminal whith wrong pattern
|
5
|
+
|
2
6
|
## [0.3.0] - 2024-02-10
|
3
7
|
- Removed collisions from different should/context methods that have the same name at different levels
|
4
8
|
## [0.2.0] - 2024-02-07
|
data/Readme.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/ruby-lsp-shoulda-context.svg)](https://badge.fury.io/rb/ruby-lsp-shoulda-context)
|
2
|
+
![Build Status](https://github.com/domingo2000/ruby-lsp-shoulda-context/actions/workflows/main.yml/badge.svg)
|
3
|
+
|
1
4
|
# RubyLsp::ShouldaContext
|
2
5
|
|
3
6
|
This gem provides support for [shoulda-context](https://github.com/thoughtbot/shoulda-context) using [ruby-lsp](https://github.com/Shopify/ruby-lsp/blob/main/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb)
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
Add the gem to the application's Gemfile `:development` group:
|
10
11
|
|
11
|
-
|
12
|
+
gem 'ruby-lsp-shoulda-context', '~> 0.4.0', require: false
|
12
13
|
|
13
14
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
15
|
|
@@ -18,6 +19,12 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
18
19
|
|
19
20
|
Just enjoy the magic of LSP with shoulda context tests!.
|
20
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
|
+
|
21
28
|
## Development
|
22
29
|
|
23
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.
|
@@ -41,7 +48,7 @@ Everyone interacting in the RubyLsp::ShouldaContext project's codebases, issue t
|
|
41
48
|
- [x] Make context runnable
|
42
49
|
- [x] Make should with string runnable
|
43
50
|
- [x] Make should with method runnable
|
44
|
-
- [
|
51
|
+
- [x] Make exec method conditional to rails or Minitest setup
|
45
52
|
- [x] Make inner context or inner should with collissions with outer DSL not collide using full name of the test (Currently if 2 tests have the same name both are executed)
|
46
53
|
- [x] Provide grouping with classes that ends with "..Test" syntax (Note: The codelens is duplicated becuase lsp support minitest by default and LSP responses are merged)
|
47
54
|
- [ ] Provide support for Inner Classes
|
@@ -3,18 +3,21 @@
|
|
3
3
|
|
4
4
|
require "ruby_lsp/addon"
|
5
5
|
require "ruby_lsp/internal"
|
6
|
+
require "dotenv/load"
|
6
7
|
|
7
8
|
require_relative "code_lens"
|
8
9
|
|
9
10
|
module RubyLsp
|
10
11
|
module ShouldaContext
|
11
|
-
# frozen_string_literal: true
|
12
|
-
|
13
12
|
class Addon < ::RubyLsp::Addon
|
14
13
|
extend T::Sig
|
15
14
|
|
16
|
-
sig { override.params(message_queue: Thread::Queue).void }
|
17
|
-
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
|
+
Dotenv.load(".env.development.local", ".env.development")
|
20
|
+
end
|
18
21
|
|
19
22
|
sig { override.void }
|
20
23
|
def deactivate; end
|
@@ -24,17 +27,8 @@ module RubyLsp
|
|
24
27
|
"Ruby LSP My Gem"
|
25
28
|
end
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
override.params(
|
30
|
-
uri: URI::Generic,
|
31
|
-
emitter: Prism::Dispatcher,
|
32
|
-
).returns(T.nilable(Listener[T::Array[Interface::CodeLens]]))
|
33
|
-
end
|
34
|
-
def create_code_lens_listener(uri, emitter)
|
35
|
-
return unless uri.to_standardized_path&.end_with?("_test.rb") || uri.to_standardized_path&.end_with?("_spec.rb")
|
36
|
-
|
37
|
-
CodeLens.new(uri, emitter)
|
30
|
+
def create_code_lens_listener(response_builder, uri, dispatcher)
|
31
|
+
CodeLens.new(response_builder, uri, dispatcher, @global_state)
|
38
32
|
end
|
39
33
|
end
|
40
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,9 +27,19 @@ module RubyLsp
|
|
27
27
|
sig { override.returns(ResponseType) }
|
28
28
|
attr_reader :_response
|
29
29
|
|
30
|
-
sig
|
31
|
-
|
32
|
-
|
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
|
41
|
+
return if ENV["RUBY_LSP_SHOULDA_CONTEXT"] == "false"
|
42
|
+
|
33
43
|
# Listener is only initialized if uri.to_standardized_path is valid
|
34
44
|
@path = T.let(T.must(uri.to_standardized_path), String)
|
35
45
|
@class_name = T.let("", String)
|
@@ -39,8 +49,6 @@ module RubyLsp
|
|
39
49
|
dispatcher.register(self, :on_call_node_enter, :on_call_node_leave, :on_class_node_enter, :on_class_node_leave)
|
40
50
|
|
41
51
|
@base_command = BASE_COMMAND
|
42
|
-
|
43
|
-
super(dispatcher)
|
44
52
|
end
|
45
53
|
|
46
54
|
sig { params(node: Prism::CallNode).void }
|
@@ -146,7 +154,7 @@ module RubyLsp
|
|
146
154
|
|
147
155
|
sig { params(node: Prism::Node, name: String, kind: Symbol).void }
|
148
156
|
def add_test_code_lens(node, name:, kind:)
|
149
|
-
return unless
|
157
|
+
return unless are_required_libraries_installed?
|
150
158
|
|
151
159
|
if kind == :class
|
152
160
|
pattern = "#{@class_name}Test"
|
@@ -171,7 +179,7 @@ module RubyLsp
|
|
171
179
|
},
|
172
180
|
]
|
173
181
|
|
174
|
-
@
|
182
|
+
@response_builder << create_code_lens(
|
175
183
|
node,
|
176
184
|
title: "Run",
|
177
185
|
command_name: "rubyLsp.runTest",
|
@@ -179,7 +187,7 @@ module RubyLsp
|
|
179
187
|
data: { type: "test", **grouping_data },
|
180
188
|
)
|
181
189
|
|
182
|
-
@
|
190
|
+
@response_builder << create_code_lens(
|
183
191
|
node,
|
184
192
|
title: "Run In Terminal",
|
185
193
|
command_name: "rubyLsp.runTestInTerminal",
|
@@ -187,7 +195,7 @@ module RubyLsp
|
|
187
195
|
data: { type: "test_in_terminal", **grouping_data },
|
188
196
|
)
|
189
197
|
|
190
|
-
@
|
198
|
+
@response_builder << create_code_lens(
|
191
199
|
node,
|
192
200
|
title: "Debug",
|
193
201
|
command_name: "rubyLsp.debugTest",
|
@@ -195,6 +203,10 @@ module RubyLsp
|
|
195
203
|
data: { type: "debug", **grouping_data },
|
196
204
|
)
|
197
205
|
end
|
206
|
+
|
207
|
+
def are_required_libraries_installed?
|
208
|
+
Bundler.locked_gems.dependencies.keys.include?(REQUIRED_LIBRARY)
|
209
|
+
end
|
198
210
|
end
|
199
211
|
end
|
200
212
|
end
|
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
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.2
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-lsp
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
20
|
-
- - "
|
19
|
+
version: 0.16.6
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.16.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
30
|
-
- - "
|
29
|
+
version: 0.16.6
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.16.0
|
33
33
|
description: An addon for the Ruby LSP that enables shoulda-context testing
|
34
34
|
email:
|
35
35
|
- domingo.edwards@uc.cl
|
@@ -37,6 +37,7 @@ executables: []
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
+
- ".env.development"
|
40
41
|
- ".rubocop.yml"
|
41
42
|
- ".ruby-version"
|
42
43
|
- CHANGELOG.md
|
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
72
|
- !ruby/object:Gem::Version
|
72
73
|
version: '0'
|
73
74
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
75
|
+
rubygems_version: 3.4.10
|
75
76
|
signing_key:
|
76
77
|
specification_version: 4
|
77
78
|
summary: Ruby LSP shoulda-context
|