be-let-it-be 0.0.2 → 0.0.4

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: 15176b1a907a256ee2b544ff198041fdce5d64599f70209d6ec498898b75ad9c
4
- data.tar.gz: 2cb16333cfb481c3392716be02a2900e837e6de27b45eff297789daf7b1f3d1c
3
+ metadata.gz: 3af3447fa48cda250b8a51276525f5bf23b873e988711fd906929c7582569bda
4
+ data.tar.gz: 7c68a3a8666b6eaf5404900bc3caf746d007daec46bbff824e437421c8b4f60a
5
5
  SHA512:
6
- metadata.gz: 7a7407883bc8103b91493f2e8e97f725967419015d6e450583d8663ee1981e26100f22c614c8e5205cbb211f4626689c51d47b3fe384235410f13c8ca82cafd4
7
- data.tar.gz: 550a4e4d787185bc322814b18f13deed3c686bfa122e27bd3259936be08a24c37be97d2aaeab8196ad01926d428b9975ce9682f2c32c507c8e507bdbf8e7dbd0
6
+ metadata.gz: da014254a11f75bc171954208268824b24f7a78e18e78897b52db374010b9fe9ba10ee5327307db514f2738824db3a5bc0b98593e0a7b851a4f2a11b3f0298e0
7
+ data.tar.gz: b87438258aa7d10167d59cdbfdcb89bc3b5e4656d2b0a848d097e2336daca34c19e6f7c7e4b5d84b767b4f86db16f339e1d33e079360acdd9249a7b88251e798
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # be-let-it-be
2
2
 
3
- [![Ruby](https://github.com/moznion/be-let-it-be/actions/workflows/main.yml/badge.svg)](https://github.com/moznion/be-let-it-be/actions/workflows/main.yml)
3
+ [![Ruby](https://github.com/moznion/be-let-it-be/actions/workflows/main.yml/badge.svg)](https://github.com/moznion/be-let-it-be/actions/workflows/main.yml) [![Gem Version](https://badge.fury.io/rb/be-let-it-be.svg?icon=si%3Arubygems)](https://badge.fury.io/rb/be-let-it-be)
4
4
 
5
5
  A command-line tool that automatically converts RSpec's `let` and `let!` declarations to `let_it_be` where it's safe to do so. The tool runs your tests after each conversion to ensure they still pass, making the optimization process safe and reliable.
6
6
 
@@ -110,6 +110,7 @@ be-let-it-be convert spec/models/user_spec.rb
110
110
  ### Options
111
111
 
112
112
  - `--dryrun` - Show what would be converted without making actual changes
113
+ - `--dryrun-exit-code` - Exit code to use in dryrun mode when any convertible declarations are present (default: 1)
113
114
  - `--verbose` - Display detailed processing information
114
115
  - `--rspec_cmd` - Customize the RSpec command used for verification (default: "rspec")
115
116
 
@@ -9,6 +9,7 @@ module BeLetItBe
9
9
  option :dryrun, type: :boolean, default: false, desc: "Show what would be converted without modifying files"
10
10
  option :verbose, type: :boolean, default: false, desc: "Show the processing output verboselly"
11
11
  option :rspec_cmd, type: :string, default: "bundle exec rspec", desc: "RSpec command to check the behaviour"
12
+ option :dryrun_exit_code, type: :numeric, default: 1, desc: "Exit code to use in dryrun mode when any convertible declarations are present"
12
13
 
13
14
  def convert(file)
14
15
  @processed_let_lines = []
@@ -34,7 +35,7 @@ module BeLetItBe
34
35
  num_of_lets = lets.length
35
36
 
36
37
  if num_of_lets.zero?
37
- say "no let/let! in the given spec; do nothing"
38
+ say "no let/let! in the given spec; do nothing"
38
39
  exit 0
39
40
  end
40
41
 
@@ -49,11 +50,11 @@ module BeLetItBe
49
50
  say "[#{processed_num}/#{num_of_lets}] Testing conversion of #{let[:type]} :#{let[:name]} at #{file}:#{let[:line]}"
50
51
 
51
52
  if converter.try_conversion_single_let(let, temp_file, -> { run_rspec(temp_file) })
52
- say " Converted to let_it_be"
53
+ say " Converted to let_it_be"
53
54
  converter = Converter.new(temp_file) # pile the converted items
54
55
  converted_count += 1
55
56
  else
56
- say " Keeping original #{let[:type]} (test failed with let_it_be)"
57
+ say " Keeping original #{let[:type]} (test failed with let_it_be)"
57
58
  end
58
59
 
59
60
  @processed_let_lines << let[:line]
@@ -61,14 +62,16 @@ module BeLetItBe
61
62
  end
62
63
 
63
64
  if converted_count > 0
65
+ say "🚀 Successfully converted #{converted_count} out of #{lets.size} definitions to let_it_be"
66
+
64
67
  if options[:dryrun]
65
68
  puts File.read(temp_file)
69
+ exit options[:dryrun_exit_code]
66
70
  else
67
71
  File.write(file, File.read(temp_file))
68
72
  end
69
- say "✅ Successfully converted #{converted_count} out of #{lets.size} definitions to let_it_be"
70
73
  else
71
- say " No conversions were possible (all tests failed with let_it_be)"
74
+ say "❣️ No conversions were possible (all tests failed with let_it_be)"
72
75
  end
73
76
  ensure
74
77
  File.unlink(temp_file) if File.exist?(temp_file)
@@ -26,8 +26,8 @@ module BeLetItBe
26
26
  def apply_single_conversion(let_info, source)
27
27
  node = let_info[:node]
28
28
 
29
- start_offset = node.message_loc.start_offset
30
- end_offset = node.message_loc.end_offset
29
+ start_offset = node.message_loc.start_character_offset
30
+ end_offset = node.message_loc.end_character_offset
31
31
 
32
32
  new_source = source.dup
33
33
  new_source[start_offset...end_offset] = "let_it_be"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeLetItBe
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: be-let-it-be
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - moznion
@@ -47,7 +47,6 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".standard.yml"
50
- - CHANGELOG.md
51
50
  - CODE_OF_CONDUCT.md
52
51
  - LICENSE.txt
53
52
  - README.md
@@ -68,7 +67,7 @@ licenses:
68
67
  metadata:
69
68
  homepage_uri: https://github.com/moznion/be-let-it-be
70
69
  source_code_uri: https://github.com/moznion/be-let-it-be
71
- changelog_uri: https://github.com/moznion/be-let-it-be/blob/main/CHANGELOG.md
70
+ changelog_uri: https://github.com/moznion/be-let-it-be/releases
72
71
  rdoc_options: []
73
72
  require_paths:
74
73
  - lib
@@ -83,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
82
  - !ruby/object:Gem::Version
84
83
  version: '0'
85
84
  requirements: []
86
- rubygems_version: 3.6.7
85
+ rubygems_version: 3.6.9
87
86
  specification_version: 4
88
87
  summary: Convert RSpec let/let! to let_it_be where possible
89
88
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2025-06-08
4
-
5
- - Initial release