ruby-lsp-shoulda-context 0.3.3 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4b10df0b5e20922d4a1fea43701d1d852e1b7cd7c12301d63052fbd0ddd261c
4
- data.tar.gz: b3771e57c473df35dc734f48852800d75a337b2e75ab5f2d0341db6902851749
3
+ metadata.gz: ef2bd21652b42fa017e458daa37597860937f8672d23f2deebf021a2530d5b34
4
+ data.tar.gz: 7cecc4559f69900a160f7649532b9d38696f70a0b29bc9ccc89edd3917d4a459
5
5
  SHA512:
6
- metadata.gz: 0aff200cb4d3e4e66af8f63b90ae3ad49aacebc1ceb47f3c1a546aa715a63fb2fd7effe1313183147ad8e55fdddb81d6ab758edf3a085d74ba3c7e4399743481
7
- data.tar.gz: ac3e55b5c6c23f934450c3a3f567b4e5a53eedac8508ee37cb163de856484988a9cfd5adc42471cc873278a58ee30e5e5ba63853bc31730554c72e8eb2ac581c
6
+ metadata.gz: 3fdd797ef37150b665104c90861fd78f1ddc525face38977876acd3edc50d7b5f4f345846b7f6df810d472d56538a307fc1928d3d96b8facda64c8df7cddbddc
7
+ data.tar.gz: 5486b8f7f137177809cfa9424dfc08909c82320835df82f01b5b23e97732dbad03a5d789c4f72c1e80cca600f9bee6cdd71df68e57cd74122873cc6d10d49bbb
data/.env.development ADDED
@@ -0,0 +1 @@
1
+ RUBY_LSP_SHOULDA_CONTEXT=true
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
- TODO: Replace `ruby-lsp-shoulda-context` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
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
- bundle add ruby-lsp-shoulda-context
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
 
@@ -41,7 +42,7 @@ Everyone interacting in the RubyLsp::ShouldaContext project's codebases, issue t
41
42
  - [x] Make context runnable
42
43
  - [x] Make should with string runnable
43
44
  - [x] Make should with method runnable
44
- - [ ] Make exec method conditional to rails or Minitest setup
45
+ - [x] Make exec method conditional to rails or Minitest setup
45
46
  - [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
47
  - [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
48
  - [ ] Provide support for Inner Classes
@@ -3,6 +3,7 @@
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
 
@@ -14,7 +15,9 @@ module RubyLsp
14
15
  extend T::Sig
15
16
 
16
17
  sig { override.params(message_queue: Thread::Queue).void }
17
- def activate(message_queue); end
18
+ def activate(message_queue)
19
+ Dotenv.load(".env.development.local", ".env.development")
20
+ end
18
21
 
19
22
  sig { override.void }
20
23
  def deactivate; end
@@ -11,11 +11,12 @@ module RubyLsp
11
11
 
12
12
  BASE_COMMAND = T.let(
13
13
  begin
14
+ cmd = File.exist?(File.join(Dir.pwd, "bin", "rails")) ? "bin/rails test" : "ruby -ITest"
14
15
  Bundler.with_original_env { Bundler.default_lockfile }
15
- "bundle exec ruby"
16
+ "bundle exec #{cmd}"
16
17
  rescue Bundler::GemfileNotFound
17
- "ruby"
18
- end + " -ITest",
18
+ cmd
19
+ end,
19
20
  String,
20
21
  )
21
22
 
@@ -28,6 +29,8 @@ module RubyLsp
28
29
 
29
30
  sig { params(uri: URI::Generic, dispatcher: Prism::Dispatcher).void }
30
31
  def initialize(uri, dispatcher)
32
+ return if ENV["RUBY_LSP_SHOULDA_CONTEXT"] == "false"
33
+
31
34
  @_response = T.let([], ResponseType)
32
35
  # Listener is only initialized if uri.to_standardized_path is valid
33
36
  @path = T.let(T.must(uri.to_standardized_path), String)
@@ -97,7 +100,7 @@ module RubyLsp
97
100
  add_test_code_lens(
98
101
  node,
99
102
  name: class_name,
100
- kind: :group,
103
+ kind: :class,
101
104
  )
102
105
  end
103
106
 
@@ -147,7 +150,13 @@ module RubyLsp
147
150
  def add_test_code_lens(node, name:, kind:)
148
151
  return unless DependencyDetector.instance.dependencies.include?(REQUIRED_LIBRARY)
149
152
 
150
- command = "#{@base_command} #{@path} -n \"/#{@pattern.strip}/\""
153
+ if kind == :class
154
+ pattern = "#{@class_name}Test"
155
+ kind = :group
156
+ else
157
+ pattern = @pattern.strip
158
+ end
159
+ command = "#{@base_command} #{@path} --name \"/#{pattern}/\""
151
160
 
152
161
  grouping_data = { group_id: @group_id_stack.last, kind: kind }
153
162
  grouping_data[:id] = @group_id if kind == :group
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RubyLsp
5
5
  module ShouldaContext
6
- VERSION = "0.3.3"
6
+ VERSION = "0.4.1"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-shoulda-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.1
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-02-10 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lsp
@@ -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