Usage
git-gamble
works with all languages and tools and editors
How to use ?
To see all available flags and options
git gamble --help
Dash -
between git
and gamble
may be only needed for --help
git-gamble --help
There are two ways to run your tests using git-gamble
:
In both cases, the test command must exit with a 0 status when there are 0 failed tests, anything else is considered as a failure
Environment variable
Setting an environment variable and run only the git gamble
command
-
Start by setting a environment variable with the test command :
The example below is for running your tests for a Rust project
export GAMBLE_TEST_COMMAND="cargo test"
Use the appropriate command for your shell :
-
Write a failing test in your codebase, then :
git gamble --red # or git gamble --fail
-
Write the minimum code to make tests pass, then :
git gamble --green # or git gamble --pass
-
Refactor your code, then :
git gamble --refactor # or git gamble --pass
DirEnv
To avoid re-exporting manually the variable at each new terminal, it's recommanded to install DirEnv
Then add in a .envrc
file
export GAMBLE_TEST_COMMAND="cargo test"
Then run this command
direnv allow
Repeating the test command
Typing the git gamble
command with your test command repetitively
-
Write a failing test in your codebase, then :
git gamble --red -- $YOUR_TEST_COMMAND
The example below is for running your tests for a NodeJS project that use pnpm
git gamble --red -- pnpm test
-
Write the minimum code to make tests pass, then :
git gamble --green -- $YOUR_TEST_COMMAND
-
Refactor your code, then :
git gamble --refactor -- $YOUR_TEST_COMMAND
Demo
For more detailed example, this the demo