retest 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b785b5164606d944a470b42899d1a7c6d4fa77f3d0d3a3850e4adc1e81d61db6
4
- data.tar.gz: d722fe7580cc3f24587322ee9d0dcc47efc4bded149d59461eb7408398f78b73
3
+ metadata.gz: 56507242c2a092f077dbad839369ce929e59bdc8e0b6c0e29436a9893d12ca79
4
+ data.tar.gz: 27eb3934eba008e23834ebec21bb42e680a143c349d33bb42c56d9b396bfed5a
5
5
  SHA512:
6
- metadata.gz: 9e7ebd3a5dd1eb6d1a09bcae184d749ac59b49cd928f845c3fcbf5d47e067e9623388167ffad4e7dc186e0aec22178444409e0da3978083107e57e7b7abcd453
7
- data.tar.gz: f0cd1516119abcc62c4dfb73d317097dc5f57d3ed741bc7ff44455c0518646c6c4ffcf44686e6ee939053a7bd435acd72fc8d4f6653123fa2816634e7abbb5a5
6
+ metadata.gz: a0fc4a62969f81110fef3630ae11a0badc4436c93cbc0502922f4f342c2ff050e449b15c5b4f949f37a6a8e755702e1b5c03741c3dccb7870401d95a67c8702e
7
+ data.tar.gz: 6042dcced199dd65e4b276f2eecc56c487f482216529079c35a84b5c133525c169dd7695d6f2d92d6c3074f6edeac50f7818a4f75ec1d1c179eca65727b5a581
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (0.3.0)
4
+ retest (0.3.1)
5
5
  listen (~> 3.2)
6
6
  string-similarity (~> 2.1)
7
7
 
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
1
  # Retest
2
2
 
3
- Retest is a small gem to help refactor code by watching a file change and running its matching spec. You don't need a configuration file to start refactoring. 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.
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
- This is my take on solving tests rerun. It is meant to be simple and follow testing conventions encountered in Ruby projects. It is probably unstable and unflexible but covers my need. Give it a go you can uninstall it easily. 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)
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
- This is a work in progress and the end goal is to have an executable that works as follow:
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
- * Works with RSpec, MiniTest, Rake commands & bash commands (not aliases).
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 the Docker container seem to work
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
Binary file
@@ -1,13 +1,11 @@
1
1
  module Retest
2
2
  class Command
3
3
  def self.for(test_command)
4
- command_class = if test_command.include? '<test>'
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
@@ -10,25 +10,28 @@ module Retest
10
10
  end
11
11
 
12
12
  def find_test(path)
13
- cache[path] ||= select_test(path)
13
+ cache[path] ||= select_from test_options(path)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def select_test(path)
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.first(5)
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
- We found few tests matching:
45
- #{list_options(tests)}
47
+ We found few tests matching:
48
+ #{list_options(tests)}
46
49
 
47
- Which file do you want to use?
48
- Enter the file number now:
50
+ Which file do you want to use?
51
+ Enter the file number now:
49
52
  QUESTION
50
53
  end
51
54
 
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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.0.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: []