retest 1.12.0 → 1.13.0

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: 4abc5ba23e0eb0898fcf7858d8427371023ff44243cf1df5b0ca7dda24eaa1ac
4
- data.tar.gz: 0d9fdf6b3db016da549af61ec4ad68716d21ec7a636f767a5459cbe94e51f9c4
3
+ metadata.gz: 1a3b868e7a077e45f1da38813aa62efe2bdefcc776c504b243d33f9841740420
4
+ data.tar.gz: 1dbb3a5cd581604f4c74122d9902f795aa59e508c3b479b667b6529e8e9d6f55
5
5
  SHA512:
6
- metadata.gz: 9792fd804aa16d444dc7dbc4df93e4f392ed357ee5d4a885a0626df919ced06aee336704a6d35b75a118642f09ad18929a132d3e5fa2416bb3353cbcdf084510
7
- data.tar.gz: e66b40a449245c4a7975502558d44b68b3093b5650d55a063f6db6bdca17022e327ff32a9ae3b3cc1c23a2ff18dc731585936f4a9122f41de64f90d7d8058524
6
+ metadata.gz: ec65a2b54baf8eabcd7f9159992cf9e90adcf111a71f258a589678305758c79ae7459bf4481d3838abff5bfc0b3acd72d7454c648fdd19105bbecc217a694142
7
+ data.tar.gz: 59f4ff3692c64c50b6a6721d1ee096150b9b8c28501ec8769f788164c8353d3e87865750c045d83c8bb22f37af081b97489ee2b83b79253420b5c364f08404c7
@@ -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,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (1.12.0)
5
- listen (~> 3.2)
4
+ retest (1.13.0)
5
+ listen (~> 3.9)
6
6
  string-similarity (~> 2.1)
7
7
  tty-option (~> 0.1)
8
8
 
@@ -11,7 +11,7 @@ GEM
11
11
  specs:
12
12
  byebug (11.1.3)
13
13
  ffi (1.16.3)
14
- listen (3.8.0)
14
+ listen (3.9.0)
15
15
  rb-fsevent (~> 0.10, >= 0.10.3)
16
16
  rb-inotify (~> 0.9, >= 0.9.10)
17
17
  minitest (5.15.0)
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.0"
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,6 @@ 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
31
  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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-05 00:00:00.000000000 Z
11
+ date: 2024-02-26 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
@@ -81,7 +81,6 @@ files:
81
81
  - bin/test/ruby-app
82
82
  - bin/test/ruby-bare
83
83
  - exe/retest
84
- - lib/config/listen.rb
85
84
  - lib/retest.rb
86
85
  - lib/retest/command.rb
87
86
  - lib/retest/command/rails.rb
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