retest 0.3.0 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -11
- data/README/demo.gif +0 -0
- data/lib/retest/command.rb +2 -4
- data/lib/retest/repository.rb +14 -11
- data/lib/retest/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56507242c2a092f077dbad839369ce929e59bdc8e0b6c0e29436a9893d12ca79
|
4
|
+
data.tar.gz: 27eb3934eba008e23834ebec21bb42e680a143c349d33bb42c56d9b396bfed5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0fc4a62969f81110fef3630ae11a0badc4436c93cbc0502922f4f342c2ff050e449b15c5b4f949f37a6a8e755702e1b5c03741c3dccb7870401d95a67c8702e
|
7
|
+
data.tar.gz: 6042dcced199dd65e4b276f2eecc56c487f482216529079c35a84b5c133525c169dd7695d6f2d92d6c3074f6edeac50f7818a4f75ec1d1c179eca65727b5a581
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# Retest
|
2
2
|
|
3
|
-
Retest is a small
|
3
|
+
Retest is a small command line tool to help refactor code by watching a file change and running its matching spec. You don't need a configuration file to start refactoring.
|
4
4
|
|
5
|
-
|
5
|
+
## Why?
|
6
|
+
It is advised to be one `cmd + z` away from green tests when refactoring. This means running tests after every line change. Let Retest rerun your tests after every file change you make.
|
6
7
|
|
7
|
-
|
8
|
+
Retest gem is meant to be simple and follow testing conventions encountered in Ruby projects. It is probably unstable and unflexible. Give it a go you can uninstall it easily. If you think the matching pattern could be improved please raise an issue.
|
8
9
|
|
9
|
-
|
10
|
-
* Works when run in a Docker container.
|
11
|
-
* When a test file is not found run the last command again.
|
12
|
-
* When multiple test files are found, ask which file to run and save the answer.
|
10
|
+
For stable, yet more and fully fledged solutions, some cli tools already exists: [autotest](https://github.com/grosser/autotest), [guard](https://github.com/guard/guard), [zentest](https://github.com/seattlerb/zentest)
|
13
11
|
|
14
12
|
## Installation
|
15
13
|
|
@@ -41,11 +39,18 @@ $ retest 'docker-compose exec web bundle exec rails test'
|
|
41
39
|
$ retest 'ruby all_tests.rb'
|
42
40
|
```
|
43
41
|
|
42
|
+
The gem works as follows:
|
43
|
+
|
44
|
+
* When multiple matching test files are found, the tool asks you to confirm the file and save the answer.
|
45
|
+
* When a test file is not found run the last command again. If no command was run before nothing gets run.
|
46
|
+
* Works with RSpec, MiniTest, Rake commands & bash commands (not aliases).
|
47
|
+
* Works when installed and run in a Docker container.
|
48
|
+
|
44
49
|
### Docker
|
45
50
|
|
46
|
-
Installing & launching the gem in
|
51
|
+
Installing & launching the gem in a Docker container seems to work
|
47
52
|
```bash
|
48
|
-
$ docker-compose run web bash
|
53
|
+
$ docker-compose run web bash
|
49
54
|
$ gem install retest
|
50
55
|
$ retest 'bundle exec rails test <test>'
|
51
56
|
```
|
@@ -57,9 +62,9 @@ $ retest 'bundle exec rails test <test>'
|
|
57
62
|
## Roadmap
|
58
63
|
|
59
64
|
- [x] MVP
|
65
|
+
- [x] When multiple test files are found, ask which file to run and save the answer.
|
66
|
+
- [x] When a test file is not found run the last command again.
|
60
67
|
- [x] Run withing Docker.
|
61
|
-
- [ ] When a test file is not found run the last command again.
|
62
|
-
- [ ] When multiple test files are found, ask which file to run and save the answer.
|
63
68
|
- [ ] Aliases from oh-my-zsh and bash profiles?
|
64
69
|
|
65
70
|
## Development
|
data/README/demo.gif
ADDED
Binary file
|
data/lib/retest/command.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
module Retest
|
2
2
|
class Command
|
3
3
|
def self.for(test_command)
|
4
|
-
|
4
|
+
if test_command.include? '<test>'
|
5
5
|
VariableCommand
|
6
6
|
else
|
7
7
|
HardcodedCommand
|
8
|
-
end
|
9
|
-
|
10
|
-
command_class.new test_command
|
8
|
+
end.new test_command
|
11
9
|
end
|
12
10
|
|
13
11
|
class VariableCommand
|
data/lib/retest/repository.rb
CHANGED
@@ -10,25 +10,28 @@ module Retest
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def find_test(path)
|
13
|
-
cache[path] ||=
|
13
|
+
cache[path] ||= select_from test_options(path)
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
19
|
-
tests = files.select { |file| regex(path) =~ file }
|
20
|
-
.sort_by { |file| String::Similarity.levenshtein(path, file) }
|
21
|
-
.reverse
|
22
|
-
|
18
|
+
def select_from(tests)
|
23
19
|
case tests.count
|
24
20
|
when 0, 1
|
25
21
|
tests.first
|
26
22
|
else
|
27
|
-
ask_question tests
|
23
|
+
ask_question tests
|
28
24
|
tests[get_input]
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
28
|
+
def test_options(path)
|
29
|
+
files.select { |file| regex(path) =~ file }
|
30
|
+
.sort_by { |file| String::Similarity.levenshtein(path, file) }
|
31
|
+
.last(5)
|
32
|
+
.reverse
|
33
|
+
end
|
34
|
+
|
32
35
|
def default_files
|
33
36
|
@default_files ||= Dir.glob('**/*') - Dir.glob('{tmp,node_modules}/**/*')
|
34
37
|
end
|
@@ -41,11 +44,11 @@ module Retest
|
|
41
44
|
|
42
45
|
def ask_question(tests)
|
43
46
|
output_stream.puts <<~QUESTION
|
44
|
-
|
45
|
-
|
47
|
+
We found few tests matching:
|
48
|
+
#{list_options(tests)}
|
46
49
|
|
47
|
-
|
48
|
-
|
50
|
+
Which file do you want to use?
|
51
|
+
Enter the file number now:
|
49
52
|
QUESTION
|
50
53
|
end
|
51
54
|
|
data/lib/retest/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.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
11
|
date: 2020-09-06 00:00:00.000000000 Z
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- alex@abletech.nz
|
72
72
|
executables:
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- Gemfile.lock
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
|
+
- README/demo.gif
|
83
84
|
- Rakefile
|
84
85
|
- bin/console
|
85
86
|
- bin/setup
|
@@ -95,7 +96,7 @@ licenses:
|
|
95
96
|
metadata:
|
96
97
|
homepage_uri: https://github.com/AlexB52/retest
|
97
98
|
source_code_uri: https://github.com/AlexB52/retest
|
98
|
-
post_install_message:
|
99
|
+
post_install_message:
|
99
100
|
rdoc_options: []
|
100
101
|
require_paths:
|
101
102
|
- lib
|
@@ -110,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
111
|
- !ruby/object:Gem::Version
|
111
112
|
version: '0'
|
112
113
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
114
|
-
signing_key:
|
114
|
+
rubygems_version: 3.1.2
|
115
|
+
signing_key:
|
115
116
|
specification_version: 4
|
116
117
|
summary: A simple command line tool to watch file change and run its matching spec.
|
117
118
|
test_files: []
|