retest 0.5.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/.github/workflows/ci.yml +39 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +6 -4
- data/README.md +40 -21
- data/exe/retest +5 -13
- data/lib/retest.rb +27 -2
- data/lib/retest/listen_options.rb +1 -1
- 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 -2
- metadata +13 -25
- data/.travis.yml +0 -6
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
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ main ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ main ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ${{ matrix.os }}
|
19
|
+
strategy:
|
20
|
+
matrix:
|
21
|
+
os: [ubuntu-latest]
|
22
|
+
ruby:
|
23
|
+
- 2.5
|
24
|
+
- 2.6
|
25
|
+
- 2.7
|
26
|
+
include:
|
27
|
+
- os: macos-latest
|
28
|
+
ruby: 2.5
|
29
|
+
name: Ruby ${{ matrix.ruby }} test (${{ matrix.os }})
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@v1
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby }}
|
36
|
+
bundler-cache: true
|
37
|
+
- run: bundle install
|
38
|
+
- run: bundle exec rake
|
39
|
+
- run: CUCUMBER_PUBLISH_QUIET=true bundle exec cucumber
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/Gemfile
CHANGED
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.
|
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)
|
@@ -93,9 +95,9 @@ PLATFORMS
|
|
93
95
|
ruby
|
94
96
|
|
95
97
|
DEPENDENCIES
|
96
|
-
aruba
|
98
|
+
aruba (~> 1.0)
|
97
99
|
byebug
|
98
|
-
cucumber
|
100
|
+
cucumber (~> 5.1)
|
99
101
|
minitest (~> 5.0)
|
100
102
|
rake (~> 12.0)
|
101
103
|
retest!
|
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,22 +64,24 @@ 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
|
|
81
|
+
## Ruby Support
|
82
|
+
|
83
|
+
Retest supports ruby 2.4 and above.
|
84
|
+
|
66
85
|
## Roadmap
|
67
86
|
|
68
87
|
- [x] MVP
|
@@ -73,7 +92,7 @@ $ retest 'bundle exec rails test <test>'
|
|
73
92
|
- [x] Bundler Gem
|
74
93
|
- [x] Rails
|
75
94
|
- [x] Ad-hoc scripts
|
76
|
-
- [
|
95
|
+
- [x] Hanami
|
77
96
|
- [ ] Sinatra
|
78
97
|
- [ ] Cuba? Padrino?
|
79
98
|
- [ ] Handle other languages: Elixir, Node, Python, PHP
|
data/exe/retest
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'retest'
|
4
|
-
require 'listen'
|
5
4
|
|
6
|
-
|
5
|
+
$stdout.sync = true
|
7
6
|
|
8
|
-
|
7
|
+
options = Retest::Options.new(ARGV)
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
command.run(modified.first.strip)
|
14
|
-
end
|
15
|
-
rescue => e
|
16
|
-
puts "Something went wrong: #{e.message}"
|
17
|
-
end
|
9
|
+
return puts options.help if options.help?
|
10
|
+
|
11
|
+
Retest.start(options.command) # not blocking
|
18
12
|
|
19
|
-
listener.start # not blocking
|
20
|
-
puts "Ready to refactor! You can make file changes now"
|
21
13
|
sleep
|
data/lib/retest.rb
CHANGED
@@ -1,10 +1,35 @@
|
|
1
|
+
require 'listen'
|
2
|
+
require 'string/similarity'
|
3
|
+
|
1
4
|
require "retest/version"
|
2
|
-
require "retest/
|
5
|
+
require "retest/runner"
|
3
6
|
require "retest/repository"
|
4
7
|
require "retest/test_options"
|
5
8
|
require "retest/listen_options"
|
6
|
-
require
|
9
|
+
require "retest/options"
|
7
10
|
|
8
11
|
module Retest
|
9
12
|
class Error < StandardError; end
|
13
|
+
|
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:)
|
24
|
+
Listen.to('.', ListenOptions.to_h) do |modified, added, removed|
|
25
|
+
begin
|
26
|
+
if modified.any?
|
27
|
+
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
28
|
+
runner.run(modified.first.strip)
|
29
|
+
end
|
30
|
+
rescue => e
|
31
|
+
puts "Something went wrong: #{e.message}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
10
35
|
end
|
@@ -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
@@ -27,6 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
spec.add_runtime_dependency "string-similarity", ["~> 2.1"]
|
29
29
|
spec.add_runtime_dependency "listen", ["~> 3.2"]
|
30
|
-
spec.
|
31
|
-
spec.add_development_dependency "aruba"
|
30
|
+
spec.add_runtime_dependency "tty-option", ["~> 0.1"]
|
32
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: 0.
|
4
|
+
version: 0.7.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: 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
|
@@ -39,33 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: tty-option
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: aruba
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
45
|
+
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
54
|
+
version: '0.1'
|
69
55
|
description:
|
70
56
|
email:
|
71
57
|
- alex@abletech.nz
|
@@ -74,8 +60,9 @@ executables:
|
|
74
60
|
extensions: []
|
75
61
|
extra_rdoc_files: []
|
76
62
|
files:
|
63
|
+
- ".github/workflows/ci.yml"
|
77
64
|
- ".gitignore"
|
78
|
-
- ".
|
65
|
+
- ".ruby-version"
|
79
66
|
- Gemfile
|
80
67
|
- Gemfile.lock
|
81
68
|
- LICENSE.txt
|
@@ -86,9 +73,10 @@ files:
|
|
86
73
|
- bin/setup
|
87
74
|
- exe/retest
|
88
75
|
- lib/retest.rb
|
89
|
-
- lib/retest/command.rb
|
90
76
|
- lib/retest/listen_options.rb
|
77
|
+
- lib/retest/options.rb
|
91
78
|
- lib/retest/repository.rb
|
79
|
+
- lib/retest/runner.rb
|
92
80
|
- lib/retest/test_options.rb
|
93
81
|
- lib/retest/version.rb
|
94
82
|
- retest.gemspec
|
@@ -113,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
101
|
- !ruby/object:Gem::Version
|
114
102
|
version: '0'
|
115
103
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.0.3
|
117
105
|
signing_key:
|
118
106
|
specification_version: 4
|
119
107
|
summary: A simple command line tool to watch file change and run its matching spec.
|