retest 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +5 -5
- data/README.md +17 -2
- data/bin/debug +4 -0
- data/exe/retest +4 -0
- data/lib/retest/options.rb +9 -0
- data/lib/retest/runners/change_runner.rb +1 -1
- data/lib/retest/runners/runner.rb +12 -2
- data/lib/retest/runners/test_runner.rb +1 -1
- data/lib/retest/runners/variable_runner.rb +1 -1
- data/lib/retest/sounds.rb +36 -0
- data/lib/retest/version.rb +1 -1
- data/lib/retest.rb +2 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 357f54e47d0b81d02f32e097cc6a0ed43b850a144bd3d368cd1a29d8d7db9b8a
|
4
|
+
data.tar.gz: e60ae5e97ffb0a75a4c75792d0ff04e8d79a3daab5ad8eaf30a300ce6ad0a858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c33d9188ecedb9b19b73b9bd0c0f7e88096d94101aa1e213dae692c6e1fe6b431f081fa7da19fcadaef1fc8984e7e7167e7f0ea269fc055a0d773afa228d6c19
|
7
|
+
data.tar.gz: 3901346f228ce16d193407fcd47cabadad28989e5d32c4d89d59bbf3344871021033b340663d634e1b3dc4478dc7e479be7351a7a7b546ba914b7de06add19c3
|
data/.github/workflows/ci.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
retest (1.
|
4
|
+
retest (1.6.0)
|
5
5
|
listen (~> 3.2)
|
6
6
|
string-similarity (~> 2.1)
|
7
7
|
tty-option (~> 0.1)
|
@@ -10,13 +10,13 @@ GEM
|
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
byebug (11.1.3)
|
13
|
-
ffi (1.15.
|
14
|
-
listen (3.7.
|
13
|
+
ffi (1.15.5)
|
14
|
+
listen (3.7.1)
|
15
15
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
16
16
|
rb-inotify (~> 0.9, >= 0.9.10)
|
17
|
-
minitest (5.
|
17
|
+
minitest (5.15.0)
|
18
18
|
rake (12.3.3)
|
19
|
-
rb-fsevent (0.11.
|
19
|
+
rb-fsevent (0.11.1)
|
20
20
|
rb-inotify (0.10.1)
|
21
21
|
ffi (~> 1.0)
|
22
22
|
string-similarity (2.1.0)
|
data/README.md
CHANGED
@@ -6,7 +6,8 @@ Retest is a small command-line tool to help you refactor code by watching a file
|
|
6
6
|
|
7
7
|
## Demo
|
8
8
|
|
9
|
-
|
9
|
+
|
10
|
+
https://user-images.githubusercontent.com/7149034/153734043-1d136f27-5c24-4676-868b-0fde76016b13.mp4
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
|
@@ -36,7 +37,11 @@ Example:
|
|
36
37
|
|
37
38
|
In this example, the feature spec `spec/features/posts_spec.rb` will be tested after any ruby file is updated.
|
38
39
|
|
39
|
-
#### 2. Run a dynamic command
|
40
|
+
#### 2. Run a dynamic command with placeholders
|
41
|
+
|
42
|
+
Retest provides few placeholders to help you run a command after every file change. The placeholders can be used on their own or together.
|
43
|
+
|
44
|
+
1. `<test>` placeholder
|
40
45
|
|
41
46
|
You can use the placeholder `<test>` to tell the gem where to put the test file path in your command. When a file is changed, the gem will find its matching test and run the test command with it.
|
42
47
|
|
@@ -45,6 +50,16 @@ Example:
|
|
45
50
|
$ retest 'bin/rails test <test>'
|
46
51
|
|
47
52
|
In this example, if `app/models/post.rb` is changed then retest will run `bin/rails test test/models/post_test.rb`
|
53
|
+
|
54
|
+
2. `<changed>` placeholder
|
55
|
+
|
56
|
+
You can use the placeholder `<changed>` to tell the gem where to put the changed file path in your command. When a file is changed, the gem will run the command with it.
|
57
|
+
|
58
|
+
Example:
|
59
|
+
|
60
|
+
$ retest 'rubocop <changed>'
|
61
|
+
|
62
|
+
In this example, if `app/models/post.rb` is changed then retest will run `rubocop app/models/post.rb`
|
48
63
|
|
49
64
|
#### 3. Run a dynamic command with shortcuts
|
50
65
|
|
data/bin/debug
CHANGED
@@ -16,6 +16,10 @@ end
|
|
16
16
|
repository = Retest::Repository.new(files: Retest::VersionControl.files)
|
17
17
|
command = Retest::Command.for_options(options)
|
18
18
|
runner = Retest::Runners.runner_for(command.to_s)
|
19
|
+
sounds = Retest::Sounds.for(options)
|
20
|
+
|
21
|
+
sounds.play(:tests_pass)
|
22
|
+
runner.add_observer(sounds)
|
19
23
|
|
20
24
|
program = Retest::Program.new(
|
21
25
|
extension: options.extension,
|
data/exe/retest
CHANGED
@@ -14,6 +14,10 @@ end
|
|
14
14
|
repository = Retest::Repository.new(files: Retest::VersionControl.files)
|
15
15
|
command = Retest::Command.for_options(options)
|
16
16
|
runner = Retest::Runners.runner_for(command.to_s)
|
17
|
+
sounds = Retest::Sounds.for(options)
|
18
|
+
|
19
|
+
sounds.play(:tests_pass)
|
20
|
+
runner.add_observer(sounds)
|
17
21
|
|
18
22
|
program = Retest::Program.new(
|
19
23
|
extension: options.extension,
|
data/lib/retest/options.rb
CHANGED
@@ -76,6 +76,11 @@ module Retest
|
|
76
76
|
desc "Indentify repository setup and runs appropriate command"
|
77
77
|
end
|
78
78
|
|
79
|
+
flag :notify do
|
80
|
+
long "--notify"
|
81
|
+
desc "Play a sound when specs pass or fail (macOS only)"
|
82
|
+
end
|
83
|
+
|
79
84
|
flag :help do
|
80
85
|
short "-h"
|
81
86
|
long "--help"
|
@@ -130,6 +135,10 @@ module Retest
|
|
130
135
|
params[:auto]
|
131
136
|
end
|
132
137
|
|
138
|
+
def notify?
|
139
|
+
params[:notify]
|
140
|
+
end
|
141
|
+
|
133
142
|
def extension
|
134
143
|
Regexp.new(params[:ext])
|
135
144
|
end
|
@@ -4,7 +4,7 @@ module Retest
|
|
4
4
|
def run(changed_file = nil, repository: nil)
|
5
5
|
if changed_file
|
6
6
|
puts "Changed File Selected: #{changed_file}"
|
7
|
-
|
7
|
+
system_run command.gsub('<changed>', changed_file)
|
8
8
|
else
|
9
9
|
puts <<~ERROR
|
10
10
|
404 - Test File Not Found
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Retest
|
2
2
|
module Runners
|
3
3
|
class Runner
|
4
|
+
include Observable
|
5
|
+
|
4
6
|
attr_accessor :command
|
5
7
|
def initialize(command)
|
6
8
|
@command = command
|
@@ -11,16 +13,24 @@ module Retest
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def run(changed_file = nil, repository: nil)
|
14
|
-
|
16
|
+
system_run command
|
15
17
|
end
|
16
18
|
|
17
19
|
def run_all_tests(tests_string)
|
18
20
|
puts "Test File Selected: #{tests_string}"
|
19
|
-
|
21
|
+
system_run command.gsub('<test>', tests_string)
|
20
22
|
end
|
21
23
|
|
22
24
|
def sync(added:, removed:)
|
23
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def system_run(command)
|
30
|
+
result = system(command) ? :tests_pass : :tests_fail
|
31
|
+
changed
|
32
|
+
notify_observers(result)
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Retest
|
2
|
+
module Sounds
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def for(options)
|
6
|
+
options.notify? ? MacOS.new : Mute.new
|
7
|
+
end
|
8
|
+
|
9
|
+
class Mute
|
10
|
+
def play(_)
|
11
|
+
end
|
12
|
+
alias update play
|
13
|
+
end
|
14
|
+
|
15
|
+
class MacOS
|
16
|
+
def initialize(kernel: Kernel, thread: Thread)
|
17
|
+
@kernel = kernel
|
18
|
+
@thread = thread
|
19
|
+
end
|
20
|
+
|
21
|
+
def play(sound)
|
22
|
+
args = case sound
|
23
|
+
when :tests_fail
|
24
|
+
['afplay', '/System/Library/Sounds/Sosumi.aiff']
|
25
|
+
when :tests_pass
|
26
|
+
['afplay', '/System/Library/Sounds/Funk.aiff']
|
27
|
+
else
|
28
|
+
raise ArgumentError.new("No sounds were found for type: #{sound}.")
|
29
|
+
end
|
30
|
+
|
31
|
+
@thread.new { @kernel.system(*args) }
|
32
|
+
end
|
33
|
+
alias update play
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/retest/version.rb
CHANGED
data/lib/retest.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'listen'
|
2
2
|
require 'string/similarity'
|
3
|
+
require 'observer'
|
3
4
|
|
4
5
|
require "retest/version"
|
5
6
|
require "retest/runners"
|
@@ -11,6 +12,7 @@ require "retest/setup"
|
|
11
12
|
require "retest/command"
|
12
13
|
require "retest/file_system"
|
13
14
|
require "retest/program"
|
15
|
+
require "retest/sounds"
|
14
16
|
|
15
17
|
module Retest
|
16
18
|
class Error < StandardError; 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.
|
4
|
+
version: 1.6.0
|
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:
|
11
|
+
date: 2022-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-similarity
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.1'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- alex@abletech.nz
|
58
58
|
executables:
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/retest/runners/test_runner.rb
|
97
97
|
- lib/retest/runners/variable_runner.rb
|
98
98
|
- lib/retest/setup.rb
|
99
|
+
- lib/retest/sounds.rb
|
99
100
|
- lib/retest/test_options.rb
|
100
101
|
- lib/retest/version.rb
|
101
102
|
- lib/retest/version_control.rb
|
@@ -108,7 +109,7 @@ licenses:
|
|
108
109
|
metadata:
|
109
110
|
homepage_uri: https://github.com/AlexB52/retest
|
110
111
|
source_code_uri: https://github.com/AlexB52/retest
|
111
|
-
post_install_message:
|
112
|
+
post_install_message:
|
112
113
|
rdoc_options: []
|
113
114
|
require_paths:
|
114
115
|
- lib
|
@@ -123,8 +124,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
127
|
+
rubygems_version: 3.1.6
|
128
|
+
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: A simple command line tool to watch file change and run its matching spec.
|
130
131
|
test_files: []
|