Skip to content

Commit

Permalink
Create version 0.7.0 and update documentation (#43)
Browse files Browse the repository at this point in the history
* Update usage help message

* Update readme usage

* Create version 0.7.0
  • Loading branch information
AlexB52 authored Dec 5, 2020
1 parent 135c034 commit 6a83544
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
retest (0.6.0)
retest (0.7.0)
listen (~> 3.2)
string-similarity (~> 2.1)
tty-option (~> 0.1)
Expand Down Expand Up @@ -62,7 +62,7 @@ GEM
ffi (1.13.1)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
listen (3.3.1)
listen (3.3.3)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
middleware (0.1.0)
Expand Down
57 changes: 36 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,46 @@ For fully fledged solutions, some cli tools already exists: [autotest](https://g
Install it on your machine with:

$ gem install retest
$ retest 'bundle exec rspec <test>'

## Usage

Launch `retest` in your terminal after accessing your ruby project folder.

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.

Learn more by running `retest -h`

```bash
# Let retest find the test file and replace the placeholder with the path of the test file
$ retest 'bundle exec rake test TEST=<test>'
$ retest 'rails test <test>'
$ retest 'rspec <test>'
$ retest 'ruby <test>'
$ retest 'docker-compose exec web bundle exec rails test <test>'

# Run the same command after a file change like all the spec files
$ retest 'bundle exec rake test'
$ retest 'rails test'
$ retest 'rspec'
$ retest 'docker-compose exec web bundle exec rails test'

# Hardcode a test file to run independently from the file you change
$ retest 'ruby all_tests.rb'
Usage: retest [OPTIONS] [COMMAND]

Watch a file change and run it matching spec.

Arguments:
COMMAND The test command to rerun when a file changes.
Use <test> placeholder to tell retest where to put the matching
spec.


Options:
--all Run all the specs of a specificied ruby setup
-h, --help Print usage
--rails Shortcut for 'bundle exec rails test <test>'
--rake Shortcut for 'bundle exec rake test TEST=<test>'
--rspec Shortcut for 'bundle exec rspec <test>'
--ruby Shortcut for 'bundle exec ruby <test>'

Examples:
Runs a matching rails test after a file change
$ retest 'bundle exec rails test <test>'
$ retest --rails

Runs all rails tests after a file change
$ retest 'bundle exec rails test'
$ retest --rails --all

Runs a hardcoded command after a file change
$ retest 'ruby lib/bottles_test.rb'
```

The gem works as follows:
Expand All @@ -47,25 +64,23 @@ The gem works as follows:
* When a test file is changed, retest will run the file test.
* When multiple matching test files are found, retest asks you to confirm the file and save the answer.
* When a test file is not found, retest runs the last run command or throw a 404.
* Works with RSpec, MiniTest, Rake commands & bash commands (not aliases).
* Works when installed and run in a Docker container.

### Docker

Installing & launching the gem in a Docker container seems to work
Retest works in Docker too. You can install the gem and launch retest in your container while refactoring.
```bash
$ docker-compose run web bash
$ docker-compose run web bash # enter your container
$ gem install retest
$ retest 'bundle exec rails test <test>'
```

**Disclaimer:**
### Disclaimer
* If an error comes in try using `bundle exec` like so: `$ retest 'bundle exec rake test <test>'`
* Aliases saved on ~/.bashrc or ~/.zshrc cannot be run that way with the `retest` command

## Ruby Support

Retest supports ruby 2.5 and above.
Retest supports ruby 2.4 and above.

## Roadmap

Expand Down
7 changes: 5 additions & 2 deletions lib/retest/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Options

command nil

desc "Watch a file change and run it matching spec"
desc "Watch a file change and run it matching spec."

example <<~EOS
Runs a matching rails test after a file change
Expand All @@ -41,7 +41,10 @@ class Options

argument :command do
optional
desc "The test command to rerun when a file changes"
desc <<~EOS
The test command to rerun when a file changes.
Use <test> placeholder to tell retest where to put the matching spec.
EOS
end

flag :all do
Expand Down
2 changes: 1 addition & 1 deletion lib/retest/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Retest
VERSION = "0.6.0"
VERSION = "0.7.0"
end
7 changes: 5 additions & 2 deletions test/retest/options/help.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Usage: retest [OPTIONS] [COMMAND]

Watch a file change and run it matching spec
Watch a file change and run it matching spec.

Arguments:
COMMAND The test command to rerun when a file changes
COMMAND The test command to rerun when a file changes.
Use <test> placeholder to tell retest where to put the matching
spec.


Options:
--all Run all the specs of a specificied ruby setup
Expand Down

0 comments on commit 6a83544

Please sign in to comment.