[go: up one dir, main page]

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

  1. 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 :

  2. Write a failing test in your codebase, then :

    git gamble --red
    # or
    git gamble --fail
    
  3. Write the minimum code to make tests pass, then :

    git gamble --green
    # or
    git gamble --pass
    
  4. 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

  1. 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
    
  2. Write the minimum code to make tests pass, then :

    git gamble --green -- $YOUR_TEST_COMMAND
    
  3. Refactor your code, then :

    git gamble --refactor -- $YOUR_TEST_COMMAND
    

Demo

For more detailed example, this the demo

asciicast