retest 1.12.0 → 1.13.1

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: 4abc5ba23e0eb0898fcf7858d8427371023ff44243cf1df5b0ca7dda24eaa1ac
4
- data.tar.gz: 0d9fdf6b3db016da549af61ec4ad68716d21ec7a636f767a5459cbe94e51f9c4
3
+ metadata.gz: feaca6389f5ca8e02d86ece50b566c59390f0f0a7a6dd488ae8bfc59f6c4d61e
4
+ data.tar.gz: c2cf300a88fbdebb073d0ebc1b0839702cf9adb06d62aea34a0f781d2c2d699a
5
5
  SHA512:
6
- metadata.gz: 9792fd804aa16d444dc7dbc4df93e4f392ed357ee5d4a885a0626df919ced06aee336704a6d35b75a118642f09ad18929a132d3e5fa2416bb3353cbcdf084510
7
- data.tar.gz: e66b40a449245c4a7975502558d44b68b3093b5650d55a063f6db6bdca17022e327ff32a9ae3b3cc1c23a2ff18dc731585936f4a9122f41de64f90d7d8058524
6
+ metadata.gz: 7e1998712f9b7df6b1d14f73f87b89836991459b6a43dccf56549147b0cf646fe38ea4362431bb7767370d55b461f7c895233c4e6ccb094a6a205021a1b30f83
7
+ data.tar.gz: 17589b1efee97f83dd1b9a2ab1333deb4f13bf6ae962dd1186fe1a0736e9976fa2e1a7313cadf96dbfea5d3bb6f9e6462d1e19cafb10628f4d3d12ec83fffa02
@@ -30,7 +30,7 @@ jobs:
30
30
  ruby: 2.5
31
31
  name: Ruby ${{ matrix.ruby }} test (${{ matrix.os }})
32
32
  steps:
33
- - uses: actions/checkout@v2
33
+ - uses: actions/checkout@v4
34
34
  - name: Set up Ruby
35
35
  uses: ruby/setup-ruby@v1
36
36
  with:
@@ -54,7 +54,7 @@ jobs:
54
54
  - rspec-ruby
55
55
  - bundler-app
56
56
  steps:
57
- - uses: actions/checkout@v2
57
+ - uses: actions/checkout@v4
58
58
  - name: Set up Ruby
59
59
  uses: ruby/setup-ruby@v1
60
60
  with:
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (1.12.0)
5
- listen (~> 3.2)
4
+ retest (1.13.1)
5
+ listen (~> 3.9)
6
+ observer (~> 0.1)
6
7
  string-similarity (~> 2.1)
7
8
  tty-option (~> 0.1)
8
9
 
@@ -11,10 +12,11 @@ GEM
11
12
  specs:
12
13
  byebug (11.1.3)
13
14
  ffi (1.16.3)
14
- listen (3.8.0)
15
+ listen (3.9.0)
15
16
  rb-fsevent (~> 0.10, >= 0.10.3)
16
17
  rb-inotify (~> 0.9, >= 0.9.10)
17
18
  minitest (5.15.0)
19
+ observer (0.1.2)
18
20
  rake (13.0.6)
19
21
  rb-fsevent (0.11.2)
20
22
  rb-inotify (0.10.1)
@@ -32,4 +34,4 @@ DEPENDENCIES
32
34
  retest!
33
35
 
34
36
  BUNDLED WITH
35
- 2.3.22
37
+ 2.4.21
data/lib/retest/prompt.rb CHANGED
@@ -19,17 +19,19 @@ module Retest
19
19
  def ask_which_test_to_use(path, files)
20
20
  changed
21
21
  notify_observers(:question)
22
+ options = options(files)
22
23
 
23
24
  output.puts(<<~QUESTION)
24
25
  We found few tests matching: #{path}
25
26
 
26
- #{list_options(files)}
27
+ #{list_options(options.keys)}
27
28
 
28
29
  Which file do you want to use?
29
30
  Enter the file number now:
30
31
  QUESTION
32
+ output.print("> ")
31
33
 
32
- files[input.gets.chomp.to_i]
34
+ options.values[input.gets.chomp.to_i]
33
35
  end
34
36
 
35
37
  def puts(*args)
@@ -42,8 +44,15 @@ module Retest
42
44
 
43
45
  private
44
46
 
45
- def list_options(files)
46
- files
47
+ def options(files, blank_option: 'none')
48
+ result = {}
49
+ files.each { |file| result[file] = file }
50
+ result[blank_option] = nil # blank option last
51
+ result
52
+ end
53
+
54
+ def list_options(options)
55
+ options
47
56
  .map
48
57
  .with_index { |file, index| "[#{index}] - #{file}" }
49
58
  .join("\n")
@@ -12,8 +12,14 @@ module Retest
12
12
  return unless path
13
13
  return if path.empty?
14
14
 
15
- @path = path
16
- cache[@path] ||= select_from MatchingOptions.for(@path, files: files)
15
+ unless cache.key?(path)
16
+ ok_to_cache, test_file = select_from path, MatchingOptions.for(path, files: files)
17
+ if ok_to_cache
18
+ cache[path] = test_file
19
+ end
20
+ end
21
+
22
+ cache[path]
17
23
  end
18
24
 
19
25
  def find_tests(paths)
@@ -49,12 +55,14 @@ module Retest
49
55
 
50
56
  private
51
57
 
52
- def select_from(tests)
53
- case tests.count
54
- when 0, 1
55
- tests.first
58
+ def select_from(path, matching_tests)
59
+ case matching_tests.count
60
+ when 0
61
+ [false, nil]
62
+ when 1
63
+ [true, matching_tests.first]
56
64
  else
57
- prompt.ask_which_test_to_use(@path, tests)
65
+ [true, prompt.ask_which_test_to_use(path, matching_tests)]
58
66
  end
59
67
  end
60
68
  end
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "1.12.0"
2
+ VERSION = "1.13.1"
3
3
  end
data/lib/retest.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'listen'
2
- require 'config/listen'
3
2
 
4
3
  require 'string/similarity'
5
4
  require 'observer'
@@ -17,6 +16,8 @@ require "retest/program"
17
16
  require "retest/prompt"
18
17
  require "retest/sounds"
19
18
 
19
+ Listen.adapter_warn_behavior = :log
20
+
20
21
  module Retest
21
22
  class Error < StandardError; end
22
23
 
data/retest.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
  spec.add_runtime_dependency "string-similarity", ["~> 2.1"]
29
- spec.add_runtime_dependency "listen", ["~> 3.2"]
29
+ spec.add_runtime_dependency "listen", ["~> 3.9"]
30
30
  spec.add_runtime_dependency "tty-option", ["~> 0.1"]
31
+ spec.add_runtime_dependency "observer", ["~> 0.1"]
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-05 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.2'
33
+ version: '3.9'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.2'
40
+ version: '3.9'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tty-option
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,21 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.1'
55
- description:
55
+ - !ruby/object:Gem::Dependency
56
+ name: observer
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ description:
56
70
  email:
57
71
  - alex@abletech.nz
58
72
  executables:
@@ -81,7 +95,6 @@ files:
81
95
  - bin/test/ruby-app
82
96
  - bin/test/ruby-bare
83
97
  - exe/retest
84
- - lib/config/listen.rb
85
98
  - lib/retest.rb
86
99
  - lib/retest/command.rb
87
100
  - lib/retest/command/rails.rb
@@ -114,7 +127,7 @@ licenses:
114
127
  metadata:
115
128
  homepage_uri: https://github.com/AlexB52/retest
116
129
  source_code_uri: https://github.com/AlexB52/retest
117
- post_install_message:
130
+ post_install_message:
118
131
  rdoc_options: []
119
132
  require_paths:
120
133
  - lib
@@ -129,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
142
  - !ruby/object:Gem::Version
130
143
  version: '0'
131
144
  requirements: []
132
- rubygems_version: 3.4.21
133
- signing_key:
145
+ rubygems_version: 3.0.3.1
146
+ signing_key:
134
147
  specification_version: 4
135
148
  summary: A simple command line tool to watch file change and run its matching spec.
136
149
  test_files: []
data/lib/config/listen.rb DELETED
@@ -1,29 +0,0 @@
1
- # lib/config/listen.rb:4: warning: method redefined; discarding old _fail
2
- # ~/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb:35: warning: previous definition of _fail was here
3
-
4
- # Runs a block of code without warnings.
5
- def silence_warnings(&block)
6
- warn_level = $VERBOSE
7
- $VERBOSE = nil
8
- result = block.call
9
- $VERBOSE = warn_level
10
- result
11
- end
12
-
13
- silence_warnings do
14
-
15
- # TODO: Update monkey patch when decision is made about
16
- # https://github.com/guard/listen/issues/572
17
-
18
- module Listen
19
- class Record
20
- class SymlinkDetector
21
- def _fail(symlinked, real_path)
22
- Listen.logger.warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
23
- raise Error, "Don't watch locally-symlinked directory twice"
24
- end
25
- end
26
- end
27
- end
28
-
29
- end