retest 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4d1cb4047340b37f649a2348b98d8fac480169a09f6276a622ddd97d6a2439b
4
- data.tar.gz: b08fa7303144c4385a45c0b3e38de202ccd9758703d97641262efbc242def2e8
3
+ metadata.gz: 5c5dc87b26d27197158d859e17e179f9dc0b00ec2280dfefff165da388c77eb6
4
+ data.tar.gz: cffbfbf72ea1b51e7f63e288fba08727498ec582192536a54ad9d2b47f04d1d2
5
5
  SHA512:
6
- metadata.gz: e75eacbeea65ef118e764a4585b373cd30a0c1742763c00b8de9d896a8b83ef8cae27a7b54e3e07704692188b3d3efc6f25dd7d1471dcebaa36916d369a7f10f
7
- data.tar.gz: bda74a90e34abd34e5d6dddac26faade5c2a3850a9cea456a4589e97096db880e3c7a8ed2ece1e1ec9174ee9ea0af4e8388173928b74b77dd4074b84efcd916f
6
+ metadata.gz: ad4051278ba14ff9f7284de5f8f643bdec7512864bb330aac803f6e3c672cc24f5584eb4b26be9f4a2b533a229fd5366a0eece8b4aa53eb816ff3e9c6575f200
7
+ data.tar.gz: 3b52308adcef24e6098f40ee07d55848f39104838c4db404394ee33a8ffe38466478cd18f347aa73b3a0072fc0c263592a9eecf1ed98e459345be160c02ed30f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (1.3.0)
4
+ retest (1.4.0)
5
5
  listen (~> 3.2)
6
6
  string-similarity (~> 2.1)
7
7
  tty-option (~> 0.1)
@@ -10,8 +10,8 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  byebug (11.1.3)
13
- ffi (1.15.3)
14
- listen (3.6.0)
13
+ ffi (1.15.4)
14
+ listen (3.7.0)
15
15
  rb-fsevent (~> 0.10, >= 0.10.3)
16
16
  rb-inotify (~> 0.9, >= 0.9.10)
17
17
  minitest (5.14.1)
data/README.md CHANGED
@@ -15,15 +15,38 @@ Install it on your machine without adding it on a Gemfile:
15
15
  $ gem install retest
16
16
 
17
17
  ## Usage
18
- ### Refactoring
19
18
 
20
- Launch `retest` in your terminal after accessing your ruby repository.
19
+ Retest is used in your terminal after accessing your ruby project folder.
21
20
 
22
- You can pass the test command surrounded by quotes and use the placeholder `<test>` to tell `retest` where to put test file in your command. Example:
21
+ ### Help
22
+
23
+ Find out what retest can do anytime with
24
+
25
+ $ retest -h
26
+
27
+ ### For Refactoring
28
+
29
+ #### 1. Run a hardcoded command
30
+
31
+ This the most simple usage of retest: running the same command over and over after each file update.
32
+
33
+ Example:
34
+
35
+ $ retest 'bundle exec rspec spec/features/posts_spec.rb'
23
36
 
24
- $ retest 'bundle exec rspec <test>'
37
+ In this example, the feature spec `spec/features/posts_spec.rb` will be tested after any ruby file is updated.
25
38
 
26
- When a file is changed, the gem will find its matching test and run the test command with it.
39
+ #### 2. Run a dynamic command
40
+
41
+ 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
+
43
+ Example:
44
+
45
+ $ retest 'bin/rails test <test>'
46
+
47
+ In this example, if `app/models/post.rb` is changed then retest will run `bin/rails test test/models/post_test.rb`
48
+
49
+ #### 3. Run a dynamic command with shortcuts
27
50
 
28
51
  Few shortcut flags exist to avoid writing the full test command.
29
52
 
@@ -31,75 +54,29 @@ Few shortcut flags exist to avoid writing the full test command.
31
54
  $ retest --rails
32
55
  $ retest --rake --all
33
56
 
34
- Or let retest find your ruby setup and run the appropriate command using:
57
+ #### 4. Let retest figure it all out
58
+
59
+ Let retest find your ruby setup and run the appropriate command using:
35
60
 
36
61
  $ retest
37
62
  $ retest --all
38
63
 
64
+ #### Running rules
65
+
39
66
  The gem works as follows:
40
67
 
41
- * When a file is changed, retest will run its matching test.
42
- * When a test files is changed, retest will run the test file.
68
+ * When a **ruby file** is changed, retest will run its matching test.
69
+ * When a **test file** is changed, retest will run the test file.
43
70
  * When multiple matching test files are found, retest asks you to confirm the file and save the answer.
44
71
  * When a test file is not found, retest runs the last run command or throw a 404.
45
72
 
46
- ### Diff Check
73
+ ### Pull request scans
47
74
 
48
- You can diff a branch and test all the relevant test files before pushing your branch and trigger the full CI suite.
75
+ You can diff a branch and test all the relevant test files before pushing your branch and trigger a full CI suite.
49
76
 
50
77
  $ retest --diff origin/main
51
78
 
52
- ### Help
53
-
54
- See more examples with `retest -h`
55
-
56
- ```
57
- Usage: retest [OPTIONS] [COMMAND]
58
-
59
- Watch a file change and run it matching spec.
60
-
61
- Arguments:
62
- COMMAND The test command to rerun when a file changes.
63
- Use <test> placeholder to tell retest where to put the matching
64
- spec.
65
-
66
-
67
- Options:
68
- --all Run all the specs of a specificied ruby setup
69
- --auto Indentify repository setup and runs appropriate
70
- command
71
- --diff=git-branch Pipes all matching tests from diffed branch to test
72
- command
73
- -h, --help Print usage
74
- --rails Shortcut for a standard Rails setup
75
- --rake Shortcut for a standard Rake setup
76
- --rspec Shortcut for a standard RSpec setup
77
- --ruby Shortcut for a Ruby project
78
-
79
- Examples:
80
- Runs a matching rails test after a file change
81
- $ retest 'bundle exec rails test <test>'
82
- $ retest --rails
83
-
84
- Runs all rails tests after a file change
85
- $ retest 'bundle exec rails test'
86
- $ retest --rails --all
87
-
88
- Runs a hardcoded command after a file change
89
- $ retest 'ruby lib/bottles_test.rb'
90
-
91
- Let retest identify which command to run
92
- $ retest
93
- $ retest --auto
94
-
95
- Let retest identify which command to run for all tests
96
- $ retest --all
97
- $ retest --auto --all
98
-
99
- Run a sanity check on changed files from a branch
100
- $ retest --diff origin/main --rails
101
- $ retest --diff main --auto
102
- ```
79
+ In this example, retest lists all the files changed between `HEAD` and `origin/main`, finds all the relevant tests and only run those.
103
80
 
104
81
  ## Why?
105
82
  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.
@@ -111,8 +88,12 @@ For fully fledged solutions, some cli tools already exists: [autotest](https://g
111
88
  ## Docker
112
89
 
113
90
  Retest works in Docker too. You can install the gem and launch retest in your container while refactoring.
91
+
114
92
  ```bash
115
- $ docker-compose run web bash # enter your container
93
+ # Enter your container. Ex:
94
+ $ docker-compose run web bash
95
+
96
+ # Install the gem and run retest in your container shell
116
97
  $ gem install retest
117
98
  $ retest 'bundle exec rails test <test>'
118
99
  ```
@@ -131,12 +112,13 @@ Retest supports ruby 2.4 and above.
131
112
  - [x] When multiple test files are found, ask which file to run and save the answer.
132
113
  - [x] When a test file is not found run the last command again.
133
114
  - [x] Run within Docker.
134
- - [ ] Handle main Ruby setups
115
+ - [x] Handle main Ruby setups
135
116
  - [x] Bundler Gem
136
117
  - [x] Rails
137
118
  - [x] Ad-hoc scripts
138
119
  - [x] Hanami
139
- - [ ] Handle other languages: Elixir, Node, Python, PHP
120
+ - [ ] Handle other languages: Go, Elixir, Node, Python, PHP
121
+ - [ ] Go (project started)
140
122
  - [ ] Aliases from oh-my-zsh and bash profiles?
141
123
 
142
124
  ## Development
@@ -149,7 +131,6 @@ To run integration tests on one setup (ex: hanami-app): `bin/test/hanami-app`
149
131
 
150
132
  To access an app container (ex: ruby-app): `docker-compose -f features/ruby-app/docker-compose.yml run retest sh`
151
133
 
152
-
153
134
  ## Contributing
154
135
 
155
136
  Bug reports and pull requests are welcome on GitHub at https://github.com/alexb52/retest.
data/bin/debug CHANGED
@@ -18,6 +18,7 @@ command = Retest::Command.for_options(options)
18
18
  runner = Retest::Runner.for(command.to_s)
19
19
 
20
20
  program = Retest::Program.new(
21
+ extension: options.extension,
21
22
  repository: repository,
22
23
  command: command,
23
24
  runner: runner
data/exe/retest CHANGED
@@ -16,6 +16,7 @@ command = Retest::Command.for_options(options)
16
16
  runner = Retest::Runner.for(command.to_s)
17
17
 
18
18
  program = Retest::Program.new(
19
+ extension: options.extension,
19
20
  repository: repository,
20
21
  command: command,
21
22
  runner: runner
@@ -60,6 +60,12 @@ module Retest
60
60
  long "--diff=git-branch"
61
61
  end
62
62
 
63
+ option :ext do
64
+ desc "Regex of file extensions to listen to"
65
+ long "--ext=regex"
66
+ default "\\.rb$"
67
+ end
68
+
63
69
  flag :all do
64
70
  long "--all"
65
71
  desc "Run all the specs of a specificied ruby setup"
@@ -124,10 +130,14 @@ module Retest
124
130
  params[:auto]
125
131
  end
126
132
 
133
+ def extension
134
+ Regexp.new(params[:ext])
135
+ end
136
+
127
137
  private
128
138
 
129
139
  def no_options_passed?
130
- params.to_h.values.compact.uniq == [false]
140
+ params.to_h.values.compact.uniq == ["\\.rb$", false]
131
141
  end
132
142
  end
133
143
  end
@@ -1,10 +1,11 @@
1
1
  module Retest
2
2
  class Program
3
- attr_accessor :runner, :repository, :command
4
- def initialize(runner: nil, repository: nil, command: nil)
3
+ attr_accessor :runner, :repository, :command, :extension
4
+ def initialize(runner: nil, repository: nil, command: nil, extension: /\.rb$/)
5
5
  @runner = runner
6
6
  @repository = repository
7
7
  @command = command
8
+ @extension = extension
8
9
  end
9
10
 
10
11
  def start
@@ -27,7 +28,7 @@ module Retest
27
28
  private
28
29
 
29
30
  def build
30
- Listen.to('.', only: /\.rb$/, relative: true) do |modified, added, removed|
31
+ Listen.to('.', only: extension, relative: true) do |modified, added, removed|
31
32
  begin
32
33
  repository.add(added)
33
34
  repository.remove(removed)
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  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.3.0
4
+ version: 1.4.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: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity