ruby-lsp-rspec 0.1.21 → 0.1.22

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: 5f01b37d539883d5abc213c66cba4c967c362ae8722a9e8c1afb4b8b39c4d069
4
- data.tar.gz: 418b518147829b9770d22b64b9c64ec89efc8f699c6b266be5be29ad08f98bc3
3
+ metadata.gz: 9f59143ad42455a57861a393b556660d68a1efddab1a34490094f3cf1d59b65d
4
+ data.tar.gz: 6239e3ccc46fe341f501fea47c6f8cce115df176e359e3f962e9e3c7068f0083
5
5
  SHA512:
6
- metadata.gz: cf2cad39b55746c3f1078235670b02e0d7dd1840327b873e19919828f3f5ac5e98929958254952089235ef0849cf52d5b2434988a2461bb70eddd406898d37fe
7
- data.tar.gz: cb4e6d74c193c5b0cd876f88d8ae6948563f7c40c988729f9d18f94e951f3517df04e3de94d40dded9e0d5f04b788497272f86443a129385ea4ded8f328b5a60
6
+ metadata.gz: 261b3ac804b0d81bcd6e615349fcf27ab70b4e6b4c5a013c9c6f510bdd153d9203457f613405cd06ea43dedaec2db02d6563e36a1a6cb635451734f709514368
7
+ data.tar.gz: 692ca7238e48d6f370d208cbcfa4264d9e7ac540f6d5a45d16c4e9da6c467230b3e5d217d93c84f42d5cf70d6b800234ed0acdcf369112a523f5bf2cbef554f7
data/README.md CHANGED
@@ -15,7 +15,7 @@ group :development do
15
15
  end
16
16
  ```
17
17
 
18
- > [!IMPORTANT]
18
+ > [!IMPORTANT]
19
19
  > Make sure the relevant features are [enabled](https://github.com/Shopify/ruby-lsp/tree/main/vscode#enable-or-disable-features) under your VSCode's `rubyLsp.enabledFeatures` setting, such as `codeLens`.
20
20
 
21
21
  After running `bundle install`, restart Ruby LSP and you should start seeing CodeLens in your RSpec test files.
@@ -56,6 +56,87 @@ In VS Code this feature can be triggered by one of the following methods:
56
56
 
57
57
  <img src="misc/go-to-definition.gif" alt="Go to definition" width="75%">
58
58
 
59
+ ### VS Code Configuration
60
+
61
+ `ruby-lsp-rspec` can be configured through VS Code's `settings.json` file.
62
+
63
+ All configuration options must be nested under the `Ruby LSP RSpec` addon within `rubyLsp.addonSettings`:
64
+
65
+ ```json
66
+ {
67
+ // ...
68
+ "rubyLsp.addonSettings": {
69
+ "Ruby LSP RSpec": {
70
+ // Configuration options go here
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ #### `rspecCommand`
77
+
78
+ **Description:**
79
+
80
+ Customize the command used to run tests via CodeLens. If not set, the command will be inferred based on the presence of a binstub or Gemfile.
81
+
82
+ **Default Value**: `nil`
83
+
84
+ **Example:**
85
+
86
+ ```json
87
+ {
88
+ // ...
89
+ "rubyLsp.addonSettings": {
90
+ "Ruby LSP RSpec": {
91
+ "rspecCommand": "rspec -f d"
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ #### `debug`
98
+
99
+ **Description:**
100
+
101
+ Enable debug logging. Currently, this only logs the RSpec command used by CodeLens to stderr, which can be viewed in VS Code's `OUTPUT` panel under `Ruby LSP`.
102
+
103
+ **Default Value**: `false`
104
+
105
+ **Example:**
106
+
107
+ ```json
108
+ {
109
+ "rubyLsp.addonSettings": {
110
+ "Ruby LSP RSpec": {
111
+ "debug": true
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Container Development
118
+
119
+ When developing in containers, use the official [`Dev Containers`](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. This ensures Ruby LSP and Ruby LSP RSpec run inside the container, allowing correct spec path resolution.
120
+
121
+ For detailed container setup instructions, see the [Ruby LSP documentation](https://github.com/Shopify/ruby-lsp/blob/main/vscode/README.md?tab=readme-ov-file#developing-on-containers).
122
+
123
+ Make sure to configure Ruby LSP to run inside the container by adding it to your `.devcontainer.json`:
124
+
125
+ ```json
126
+ {
127
+ "name": "my-app",
128
+ // ...
129
+ "customizations": {
130
+ "vscode": {
131
+ "extensions": [
132
+ "Shopify.ruby-lsp",
133
+ // ...
134
+ ]
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
59
140
  ## Development
60
141
 
61
142
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -14,9 +14,26 @@ module RubyLsp
14
14
  class Addon < ::RubyLsp::Addon
15
15
  extend T::Sig
16
16
 
17
+ sig { returns(T.nilable(String)) }
18
+ attr_reader :rspec_command
19
+
20
+ sig { returns(T::Boolean) }
21
+ attr_reader :debug
22
+
23
+ sig { void }
24
+ def initialize
25
+ super
26
+ @debug = T.let(false, T::Boolean)
27
+ @rspec_command = T.let(nil, T.nilable(String))
28
+ end
29
+
17
30
  sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
18
31
  def activate(global_state, message_queue)
19
32
  @index = T.let(global_state.index, T.nilable(RubyIndexer::Index))
33
+
34
+ settings = global_state.settings_for_addon(name)
35
+ @rspec_command = T.let(settings&.dig(:rspecCommand), T.nilable(String))
36
+ @debug = settings&.dig(:debug) || false
20
37
  end
21
38
 
22
39
  sig { override.void }
@@ -38,7 +55,7 @@ module RubyLsp
38
55
  def create_code_lens_listener(response_builder, uri, dispatcher)
39
56
  return unless uri.to_standardized_path&.end_with?("_test.rb") || uri.to_standardized_path&.end_with?("_spec.rb")
40
57
 
41
- CodeLens.new(response_builder, uri, dispatcher)
58
+ CodeLens.new(response_builder, uri, dispatcher, rspec_command: rspec_command, debug: debug)
42
59
  end
43
60
 
44
61
  sig do
@@ -13,9 +13,11 @@ module RubyLsp
13
13
  response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
14
14
  uri: URI::Generic,
15
15
  dispatcher: Prism::Dispatcher,
16
+ rspec_command: T.nilable(String),
17
+ debug: T::Boolean,
16
18
  ).void
17
19
  end
18
- def initialize(response_builder, uri, dispatcher)
20
+ def initialize(response_builder, uri, dispatcher, rspec_command: nil, debug: false)
19
21
  @response_builder = response_builder
20
22
  # Listener is only initialized if uri.to_standardized_path is valid
21
23
  @path = T.let(T.must(uri.to_standardized_path), String)
@@ -24,8 +26,10 @@ module RubyLsp
24
26
  @anonymous_example_count = T.let(0, Integer)
25
27
  dispatcher.register(self, :on_call_node_enter, :on_call_node_leave)
26
28
 
29
+ @debug = debug
27
30
  @base_command = T.let(
28
- begin
31
+ # The user-configured command takes precedence over inferred command default
32
+ rspec_command || begin
29
33
  cmd = if File.exist?(File.join(Dir.pwd, "bin", "rspec"))
30
34
  "bin/rspec"
31
35
  else
@@ -71,6 +75,11 @@ module RubyLsp
71
75
 
72
76
  private
73
77
 
78
+ sig { params(message: String).void }
79
+ def log_message(message)
80
+ puts "[#{self.class}]: #{message}"
81
+ end
82
+
74
83
  sig { params(node: Prism::CallNode).returns(T::Boolean) }
75
84
  def valid_group?(node)
76
85
  !(node.block.nil? || (node.receiver && node.receiver&.slice != "RSpec"))
@@ -104,6 +113,8 @@ module RubyLsp
104
113
  line_number = node.location.start_line
105
114
  command = "#{@base_command} #{@path}:#{line_number}"
106
115
 
116
+ log_message("Full command: `#{command}`") if @debug
117
+
107
118
  grouping_data = { group_id: @group_id_stack.last, kind: kind }
108
119
  grouping_data[:id] = @group_id if kind == :group
109
120
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RubyLsp
5
5
  module RSpec
6
- VERSION = "0.1.21"
6
+ VERSION = "0.1.22"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stan Lo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-25 00:00:00.000000000 Z
11
+ date: 2025-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lsp