retest 0.6.0 → 0.7.0
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 +4 -2
- data/README.md +36 -21
- data/exe/retest +3 -5
- data/lib/retest.rb +13 -3
- data/lib/retest/options.rb +114 -0
- data/lib/retest/{command.rb → runner.rb} +5 -5
- data/lib/retest/version.rb +1 -1
- data/retest.gemspec +1 -0
- metadata +22 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e161cc74886493796c719db9fae3f3d7b7dc31dfedc701539383e406d97336f
|
4
|
+
data.tar.gz: dd6489fed59acfa0ccede581cae6a6e719a6c803a83214536e1aeed3173d6565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b4a4c521cc8f24d4f03e496aff11dee753e57e33e072e05dd24e01be82e300ad01a0d4f895f65115904395dde3833ee927932ba9b94a03f69fcbefe39e7c6ae
|
7
|
+
data.tar.gz: a9d7acc12519dc1be69be17c36f504035a7a2505d248636090e008ae1555e1d69eca7f85c0ceb9fdc6b5b8868a1f79083ae06673f762315a7f88dffd22f00009
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
retest (0.
|
4
|
+
retest (0.7.0)
|
5
5
|
listen (~> 3.2)
|
6
6
|
string-similarity (~> 2.1)
|
7
|
+
tty-option (~> 0.1)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -61,7 +62,7 @@ GEM
|
|
61
62
|
ffi (1.13.1)
|
62
63
|
i18n (1.8.5)
|
63
64
|
concurrent-ruby (~> 1.0)
|
64
|
-
listen (3.3.
|
65
|
+
listen (3.3.3)
|
65
66
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
66
67
|
rb-inotify (~> 0.9, >= 0.9.10)
|
67
68
|
middleware (0.1.0)
|
@@ -85,6 +86,7 @@ GEM
|
|
85
86
|
ffi (>= 1.0.0)
|
86
87
|
thor (1.0.1)
|
87
88
|
thread_safe (0.3.6)
|
89
|
+
tty-option (0.1.0)
|
88
90
|
tzinfo (1.2.7)
|
89
91
|
thread_safe (~> 0.1)
|
90
92
|
zeitwerk (2.4.0)
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ For fully fledged solutions, some cli tools already exists: [autotest](https://g
|
|
16
16
|
Install it on your machine with:
|
17
17
|
|
18
18
|
$ gem install retest
|
19
|
+
$ retest 'bundle exec rspec <test>'
|
19
20
|
|
20
21
|
## Usage
|
21
22
|
|
@@ -23,22 +24,38 @@ Launch `retest` in your terminal after accessing your ruby project folder.
|
|
23
24
|
|
24
25
|
Pass the test command surrounded by quotes. Use the placeholder `<test>` in your command to let `retest` find the matching test and replace the placeholder with the path of the test file.
|
25
26
|
|
27
|
+
Learn more by running `retest -h`
|
28
|
+
|
26
29
|
```bash
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
Usage: retest [OPTIONS] [COMMAND]
|
31
|
+
|
32
|
+
Watch a file change and run it matching spec.
|
33
|
+
|
34
|
+
Arguments:
|
35
|
+
COMMAND The test command to rerun when a file changes.
|
36
|
+
Use <test> placeholder to tell retest where to put the matching
|
37
|
+
spec.
|
38
|
+
|
39
|
+
|
40
|
+
Options:
|
41
|
+
--all Run all the specs of a specificied ruby setup
|
42
|
+
-h, --help Print usage
|
43
|
+
--rails Shortcut for 'bundle exec rails test <test>'
|
44
|
+
--rake Shortcut for 'bundle exec rake test TEST=<test>'
|
45
|
+
--rspec Shortcut for 'bundle exec rspec <test>'
|
46
|
+
--ruby Shortcut for 'bundle exec ruby <test>'
|
47
|
+
|
48
|
+
Examples:
|
49
|
+
Runs a matching rails test after a file change
|
50
|
+
$ retest 'bundle exec rails test <test>'
|
51
|
+
$ retest --rails
|
52
|
+
|
53
|
+
Runs all rails tests after a file change
|
54
|
+
$ retest 'bundle exec rails test'
|
55
|
+
$ retest --rails --all
|
56
|
+
|
57
|
+
Runs a hardcoded command after a file change
|
58
|
+
$ retest 'ruby lib/bottles_test.rb'
|
42
59
|
```
|
43
60
|
|
44
61
|
The gem works as follows:
|
@@ -47,25 +64,23 @@ The gem works as follows:
|
|
47
64
|
* When a test file is changed, retest will run the file test.
|
48
65
|
* When multiple matching test files are found, retest asks you to confirm the file and save the answer.
|
49
66
|
* When a test file is not found, retest runs the last run command or throw a 404.
|
50
|
-
* Works with RSpec, MiniTest, Rake commands & bash commands (not aliases).
|
51
|
-
* Works when installed and run in a Docker container.
|
52
67
|
|
53
68
|
### Docker
|
54
69
|
|
55
|
-
|
70
|
+
Retest works in Docker too. You can install the gem and launch retest in your container while refactoring.
|
56
71
|
```bash
|
57
|
-
$ docker-compose run web bash
|
72
|
+
$ docker-compose run web bash # enter your container
|
58
73
|
$ gem install retest
|
59
74
|
$ retest 'bundle exec rails test <test>'
|
60
75
|
```
|
61
76
|
|
62
|
-
|
77
|
+
### Disclaimer
|
63
78
|
* If an error comes in try using `bundle exec` like so: `$ retest 'bundle exec rake test <test>'`
|
64
79
|
* Aliases saved on ~/.bashrc or ~/.zshrc cannot be run that way with the `retest` command
|
65
80
|
|
66
81
|
## Ruby Support
|
67
82
|
|
68
|
-
Retest supports ruby 2.
|
83
|
+
Retest supports ruby 2.4 and above.
|
69
84
|
|
70
85
|
## Roadmap
|
71
86
|
|
data/exe/retest
CHANGED
@@ -4,12 +4,10 @@ require 'retest'
|
|
4
4
|
|
5
5
|
$stdout.sync = true
|
6
6
|
|
7
|
-
|
7
|
+
options = Retest::Options.new(ARGV)
|
8
8
|
|
9
|
-
|
10
|
-
.build(command: Retest::Command.for(ARGV.join))
|
11
|
-
.start # not blocking
|
9
|
+
return puts options.help if options.help?
|
12
10
|
|
13
|
-
|
11
|
+
Retest.start(options.command) # not blocking
|
14
12
|
|
15
13
|
sleep
|
data/lib/retest.rb
CHANGED
@@ -2,20 +2,30 @@ require 'listen'
|
|
2
2
|
require 'string/similarity'
|
3
3
|
|
4
4
|
require "retest/version"
|
5
|
-
require "retest/
|
5
|
+
require "retest/runner"
|
6
6
|
require "retest/repository"
|
7
7
|
require "retest/test_options"
|
8
8
|
require "retest/listen_options"
|
9
|
+
require "retest/options"
|
9
10
|
|
10
11
|
module Retest
|
11
12
|
class Error < StandardError; end
|
12
13
|
|
13
|
-
def self.
|
14
|
+
def self.start(command)
|
15
|
+
puts "Launching Retest..."
|
16
|
+
|
17
|
+
build(runner: Retest::Runner.for(command))
|
18
|
+
.start
|
19
|
+
|
20
|
+
puts "Ready to refactor! You can make file changes now"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.build(runner:)
|
14
24
|
Listen.to('.', ListenOptions.to_h) do |modified, added, removed|
|
15
25
|
begin
|
16
26
|
if modified.any?
|
17
27
|
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
18
|
-
|
28
|
+
runner.run(modified.first.strip)
|
19
29
|
end
|
20
30
|
rescue => e
|
21
31
|
puts "Something went wrong: #{e.message}"
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'tty-option'
|
2
|
+
|
3
|
+
module Retest
|
4
|
+
class Options
|
5
|
+
include TTY::Option
|
6
|
+
|
7
|
+
RSPEC_COMMAND = "bundle exec rspec <test>"
|
8
|
+
RAILS_COMMAND = "bundle exec rails test <test>"
|
9
|
+
RAKE_COMMAND = "bundle exec rake test TEST=<test>"
|
10
|
+
RUBY_COMMAND = "bundle exec ruby <test>"
|
11
|
+
NO_COMMAND = "echo You have no command assigned"
|
12
|
+
|
13
|
+
ALL_RAKE_COMMAND = "bundle exec rake test"
|
14
|
+
ALL_RAILS_COMMAND = "bundle exec rails test"
|
15
|
+
ALL_RSPEC_COMMAND = "bundle exec rspec"
|
16
|
+
|
17
|
+
usage do
|
18
|
+
program "retest"
|
19
|
+
|
20
|
+
command nil
|
21
|
+
|
22
|
+
desc "Watch a file change and run it matching spec."
|
23
|
+
|
24
|
+
example <<~EOS
|
25
|
+
Runs a matching rails test after a file change
|
26
|
+
$ retest 'bundle exec rails test <test>'
|
27
|
+
$ retest --rails
|
28
|
+
EOS
|
29
|
+
|
30
|
+
example <<~EOS
|
31
|
+
Runs all rails tests after a file change
|
32
|
+
$ retest 'bundle exec rails test'
|
33
|
+
$ retest --rails --all
|
34
|
+
EOS
|
35
|
+
|
36
|
+
example <<~EOS
|
37
|
+
Runs a hardcoded command after a file change
|
38
|
+
$ retest 'ruby lib/bottles_test.rb'
|
39
|
+
EOS
|
40
|
+
end
|
41
|
+
|
42
|
+
argument :command do
|
43
|
+
optional
|
44
|
+
desc <<~EOS
|
45
|
+
The test command to rerun when a file changes.
|
46
|
+
Use <test> placeholder to tell retest where to put the matching spec.
|
47
|
+
EOS
|
48
|
+
end
|
49
|
+
|
50
|
+
flag :all do
|
51
|
+
long "--all"
|
52
|
+
desc "Run all the specs of a specificied ruby setup"
|
53
|
+
end
|
54
|
+
|
55
|
+
flag :help do
|
56
|
+
short "-h"
|
57
|
+
long "--help"
|
58
|
+
desc "Print usage"
|
59
|
+
end
|
60
|
+
|
61
|
+
flag :rspec do
|
62
|
+
long "--rspec"
|
63
|
+
desc "Shortcut for '#{RSPEC_COMMAND}'"
|
64
|
+
end
|
65
|
+
|
66
|
+
flag :rake do
|
67
|
+
long "--rake"
|
68
|
+
desc "Shortcut for '#{RAKE_COMMAND}'"
|
69
|
+
end
|
70
|
+
|
71
|
+
flag :rails do
|
72
|
+
long "--rails"
|
73
|
+
desc "Shortcut for '#{RAILS_COMMAND}'"
|
74
|
+
end
|
75
|
+
|
76
|
+
flag :ruby do
|
77
|
+
long "--ruby"
|
78
|
+
desc "Shortcut for '#{RUBY_COMMAND}'"
|
79
|
+
end
|
80
|
+
|
81
|
+
attr_reader :args
|
82
|
+
|
83
|
+
def self.command(args)
|
84
|
+
new(args).command
|
85
|
+
end
|
86
|
+
|
87
|
+
def initialize(args = [])
|
88
|
+
self.args = args
|
89
|
+
end
|
90
|
+
|
91
|
+
def command
|
92
|
+
if params[:rspec]
|
93
|
+
params[:all] ? ALL_RSPEC_COMMAND : RSPEC_COMMAND
|
94
|
+
elsif params[:rake]
|
95
|
+
params[:all] ? ALL_RAKE_COMMAND : RAKE_COMMAND
|
96
|
+
elsif params[:rails]
|
97
|
+
params[:all] ? ALL_RAILS_COMMAND : RAILS_COMMAND
|
98
|
+
elsif params[:ruby]
|
99
|
+
params[:all] ? NO_COMMAND : RUBY_COMMAND
|
100
|
+
else
|
101
|
+
params[:command] || NO_COMMAND
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def args=(args)
|
106
|
+
@args = args
|
107
|
+
parse args
|
108
|
+
end
|
109
|
+
|
110
|
+
def help?
|
111
|
+
params[:help]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Retest
|
2
|
-
class
|
2
|
+
class Runner
|
3
3
|
def self.for(test_command)
|
4
4
|
if test_command.include? '<test>'
|
5
|
-
|
5
|
+
VariableRunner
|
6
6
|
else
|
7
|
-
|
7
|
+
HardcodedRunner
|
8
8
|
end.new test_command
|
9
9
|
end
|
10
10
|
|
11
|
-
class
|
11
|
+
class VariableRunner
|
12
12
|
attr_reader :command, :repository, :cached_test_file
|
13
13
|
|
14
14
|
def initialize(command, repository: nil)
|
@@ -37,7 +37,7 @@ module Retest
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
HardcodedRunner = Struct.new(:command) do
|
41
41
|
def run(_)
|
42
42
|
system command
|
43
43
|
end
|
data/lib/retest/version.rb
CHANGED
data/retest.gemspec
CHANGED
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: 0.
|
4
|
+
version: 0.7.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: 2020-
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-similarity
|
@@ -38,7 +38,21 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.2'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-option
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
55
|
+
description:
|
42
56
|
email:
|
43
57
|
- alex@abletech.nz
|
44
58
|
executables:
|
@@ -59,9 +73,10 @@ files:
|
|
59
73
|
- bin/setup
|
60
74
|
- exe/retest
|
61
75
|
- lib/retest.rb
|
62
|
-
- lib/retest/command.rb
|
63
76
|
- lib/retest/listen_options.rb
|
77
|
+
- lib/retest/options.rb
|
64
78
|
- lib/retest/repository.rb
|
79
|
+
- lib/retest/runner.rb
|
65
80
|
- lib/retest/test_options.rb
|
66
81
|
- lib/retest/version.rb
|
67
82
|
- retest.gemspec
|
@@ -71,7 +86,7 @@ licenses:
|
|
71
86
|
metadata:
|
72
87
|
homepage_uri: https://github.com/AlexB52/retest
|
73
88
|
source_code_uri: https://github.com/AlexB52/retest
|
74
|
-
post_install_message:
|
89
|
+
post_install_message:
|
75
90
|
rdoc_options: []
|
76
91
|
require_paths:
|
77
92
|
- lib
|
@@ -87,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
102
|
version: '0'
|
88
103
|
requirements: []
|
89
104
|
rubygems_version: 3.0.3
|
90
|
-
signing_key:
|
105
|
+
signing_key:
|
91
106
|
specification_version: 4
|
92
107
|
summary: A simple command line tool to watch file change and run its matching spec.
|
93
108
|
test_files: []
|