retest 1.6.1 → 1.8.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: 1574e44c17347c9a6e737481bfcbff782800cf68baef56f7f1dc2e1006f4f5b6
4
- data.tar.gz: abe7fda8889c342859457f87b44a91e6e9e4a8cd0d8c764d6738422a8c9ed087
3
+ metadata.gz: 89898cfd99c7a977326f854924113de57fe34273748eaabadae36ebf8a9995db
4
+ data.tar.gz: cbdd88f75d340d6ea46bc878ee9083a4b335b25c0014d3cf72de18dbe1bb3b2a
5
5
  SHA512:
6
- metadata.gz: 9732e40769bbdc74ec7783dede4255c6cfb64a2517a8a92cffcbb838b54b714cd71f4244f7c06c6e238ce008facbd4e49f5fd0e6a4c5d73e2c225328254cf427
7
- data.tar.gz: 791f6b3bf4d6b8b1eec931bff738bd6e795d51a41c17263c9ab6c0e47d15e1acfd70d18679387ce40520b871c8aabb184f4298f84a965c8e4c43b0b990465b62
6
+ metadata.gz: cac17fe3587fa15b76f6c6fc13463bc5b9d5d3cfe2ca8d8ca57e67b7a5cbdb630905f3d74ddbeea00c1a3b16a176928222db29b10ecf6ad684020718519966e5
7
+ data.tar.gz: 3f6b4e80e958f5de28fd35e2c0c32954d96061729190d9d88228c7fd0c1cdf8c176afcf3f45cbd9e7f48cfead91834cd5fe4f8ba26db6a804b9f163fafd6a32c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (1.6.0)
4
+ retest (1.8.0)
5
5
  listen (~> 3.2)
6
6
  string-similarity (~> 2.1)
7
7
  tty-option (~> 0.1)
data/exe/retest CHANGED
@@ -16,7 +16,7 @@ command = Retest::Command.for_options(options)
16
16
  runner = Retest::Runners.runner_for(command.to_s)
17
17
  sounds = Retest::Sounds.for(options)
18
18
 
19
- sounds.play(:tests_pass)
19
+ sounds.play(:start)
20
20
  runner.add_observer(sounds)
21
21
 
22
22
  program = Retest::Program.new(
@@ -30,16 +30,21 @@ if options.params[:diff]
30
30
  return
31
31
  end
32
32
 
33
+ launching_message = "Launching Retest..."
34
+ if options.force_polling?
35
+ launching_message = "Launching Retest with polling method..."
36
+ end
37
+
33
38
  # Main action
34
39
 
35
- $stdout.puts "Launching Retest..."
36
- Listen.to('.', only: options.extension, relative: true) do |modified, added, removed|
40
+ $stdout.puts launching_message
41
+ Retest.listen(options) do |modified, added, removed|
37
42
  begin
38
43
  program.run(modified, added, removed)
39
44
  rescue => e
40
45
  $stdout.puts "Something went wrong: #{e.message}"
41
46
  end
42
- end.start
47
+ end
43
48
  $stdout.puts "Ready to refactor! You can make file changes now"
44
49
 
45
50
  # not blocking
@@ -26,7 +26,6 @@ module Retest
26
26
  end
27
27
 
28
28
  def command
29
- return default_command if auto?
30
29
  options_command || default_command
31
30
  end
32
31
 
@@ -13,13 +13,18 @@ module Retest
13
13
 
14
14
  example <<~EOS
15
15
  Runs a matching rails test after a file change
16
- $ retest 'bundle exec rails test <test>'
16
+ $ retest 'bin/rails test <test>'
17
17
  $ retest --rails
18
18
  EOS
19
19
 
20
+ example <<~EOS
21
+ Runs rubocop and matching rails test after a file change
22
+ $ retest 'rubocop <changed> && bin/rails test <test>'
23
+ EOS
24
+
20
25
  example <<~EOS
21
26
  Runs all rails tests after a file change
22
- $ retest 'bundle exec rails test'
27
+ $ retest 'bin/rails test'
23
28
  $ retest --rails --all
24
29
  EOS
25
30
 
@@ -31,19 +36,17 @@ module Retest
31
36
  example <<~EOS
32
37
  Let retest identify which command to run
33
38
  $ retest
34
- $ retest --auto
35
39
  EOS
36
40
 
37
41
  example <<~EOS
38
42
  Let retest identify which command to run for all tests
39
43
  $ retest --all
40
- $ retest --auto --all
41
44
  EOS
42
45
 
43
46
  example <<~EOS
44
47
  Run a sanity check on changed files from a branch
48
+ $ retest --diff main
45
49
  $ retest --diff origin/main --rails
46
- $ retest --diff main --auto
47
50
  EOS
48
51
  end
49
52
 
@@ -51,7 +54,7 @@ module Retest
51
54
  optional
52
55
  desc <<~EOS
53
56
  The test command to rerun when a file changes.
54
- Use <test> placeholder to tell retest where to put the matching spec.
57
+ Use <test> or <changed> placeholders to tell retest where to reference the matching spec or the changed file in the command.
55
58
  EOS
56
59
  end
57
60
 
@@ -71,11 +74,6 @@ module Retest
71
74
  desc "Run all the specs of a specificied ruby setup"
72
75
  end
73
76
 
74
- flag :auto do
75
- long "--auto"
76
- desc "Indentify repository setup and runs appropriate command"
77
- end
78
-
79
77
  flag :notify do
80
78
  long "--notify"
81
79
  desc "Play a sound when specs pass or fail (macOS only)"
@@ -87,6 +85,15 @@ module Retest
87
85
  desc "Print usage"
88
86
  end
89
87
 
88
+ option :polling do
89
+ long '--polling'
90
+ desc <<~DESC.strip
91
+ Use polling method when listening to file changes
92
+ Some filesystems won't work without it
93
+ VM/Vagrant Shared folders, NFS, Samba, sshfs...
94
+ DESC
95
+ end
96
+
90
97
  flag :rspec do
91
98
  long "--rspec"
92
99
  desc "Shortcut for a standard RSpec setup"
@@ -130,23 +137,16 @@ module Retest
130
137
  params[:all]
131
138
  end
132
139
 
133
- def auto?
134
- return true if no_options_passed?
135
- params[:auto]
136
- end
137
-
138
140
  def notify?
139
141
  params[:notify]
140
142
  end
141
143
 
142
- def extension
143
- Regexp.new(params[:ext])
144
+ def force_polling?
145
+ params[:polling]
144
146
  end
145
147
 
146
- private
147
-
148
- def no_options_passed?
149
- params.to_h.values.compact.uniq == ["\\.rb$", false]
148
+ def extension
149
+ Regexp.new(params[:ext])
150
150
  end
151
151
  end
152
152
  end
@@ -16,7 +16,7 @@ module Retest
16
16
 
17
17
  log(<<~FILES)
18
18
  Files Selected:
19
- - file: #{changed_file}
19
+ - changed: #{changed_file}
20
20
  - test: #{cached_test_file}
21
21
 
22
22
  FILES
data/lib/retest/sounds.rb CHANGED
@@ -24,6 +24,8 @@ module Retest
24
24
  ['afplay', '/System/Library/Sounds/Sosumi.aiff']
25
25
  when :tests_pass
26
26
  ['afplay', '/System/Library/Sounds/Funk.aiff']
27
+ when :start
28
+ ['afplay', '/System/Library/Sounds/Blow.aiff']
27
29
  else
28
30
  raise ArgumentError.new("No sounds were found for type: #{sound}.")
29
31
  end
@@ -33,4 +35,20 @@ module Retest
33
35
  alias update play
34
36
  end
35
37
  end
36
- end
38
+ end
39
+
40
+ # List of Mac Audio Files:
41
+ # afplay /System/Library/Sounds/Basso.aiff
42
+ # afplay /System/Library/Sounds/Bottle.aiff
43
+ # afplay /System/Library/Sounds/Funk.aiff
44
+ # afplay /System/Library/Sounds/Hero.aiff
45
+ # afplay /System/Library/Sounds/Ping.aiff
46
+ # afplay /System/Library/Sounds/Purr.aiff
47
+ # afplay /System/Library/Sounds/Submarine.aiff
48
+ # afplay /System/Library/Sounds/Blow.aiff
49
+ # afplay /System/Library/Sounds/Frog.aiff
50
+ # afplay /System/Library/Sounds/Glass.aiff
51
+ # afplay /System/Library/Sounds/Morse.aiff
52
+ # afplay /System/Library/Sounds/Pop.aiff
53
+ # afplay /System/Library/Sounds/Sosumi.aiff
54
+ # afplay /System/Library/Sounds/Tink.aiff
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "1.6.1"
2
+ VERSION = "1.8.0"
3
3
  end
data/lib/retest.rb CHANGED
@@ -16,4 +16,10 @@ require "retest/sounds"
16
16
 
17
17
  module Retest
18
18
  class Error < StandardError; end
19
+
20
+ def self.listen(options, listener: Listen)
21
+ listener.to('.', only: options.extension, relative: true, force_polling: options.force_polling?) do |modified, added, removed|
22
+ yield modified, added, removed
23
+ end.start
24
+ end
19
25
  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.6.1
4
+ version: 1.8.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: 2022-06-26 00:00:00.000000000 Z
11
+ date: 2022-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity