From 7c89dde205c03e953388d7d177f958506a63b003 Mon Sep 17 00:00:00 2001 From: Chris Stone Date: Mon, 21 Jul 2025 06:05:45 -0600 Subject: [PATCH] Add shellspec and bats tests --- README.md | 12 ++++++++++++ spec/git_flow_init_spec.sh | 25 +++++++++++++++++++++++++ test/git_flow_version.bats | 7 +++++++ 3 files changed, 44 insertions(+) create mode 100644 spec/git_flow_init_spec.sh create mode 100755 test/git_flow_version.bats diff --git a/README.md b/README.md index af2e30a..39c4240 100644 --- a/README.md +++ b/README.md @@ -234,3 +234,15 @@ in another way, however, consider donating through PayPal: [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=GU25NCHMVMT9U) + +## Running tests + +This project uses [ShellSpec](https://shellspec.info/) for BDD-level scenarios and [Bats](https://bats-core.readthedocs.io/) for unit tests. + +To execute the test suites run: + +```sh +shellspec +bats test +``` + diff --git a/spec/git_flow_init_spec.sh b/spec/git_flow_init_spec.sh new file mode 100644 index 0000000..c01c7e9 --- /dev/null +++ b/spec/git_flow_init_spec.sh @@ -0,0 +1,25 @@ +Describe 'git flow init with defaults' + BeforeAll setup + AfterAll teardown + + setup() { + TEST_DIR=$(mktemp -d) + cd "$TEST_DIR" + git init -q + /workspace/gitflow-cjs/git-flow init -d >/dev/null + } + + teardown() { + rm -rf "$TEST_DIR" + } + + It 'creates develop branch' + When run git rev-parse --verify develop + The status should be success + End + + It 'stores branch configuration' + When run git config gitflow.branch.master + The output should eq 'master' + End +End diff --git a/test/git_flow_version.bats b/test/git_flow_version.bats new file mode 100755 index 0000000..00bab4d --- /dev/null +++ b/test/git_flow_version.bats @@ -0,0 +1,7 @@ +#!/usr/bin/env bats + +@test "git flow version prints expected output" { + run /workspace/gitflow-cjs/git-flow version + [ "$status" -eq 0 ] + [ "$output" = "2.2.1 (CJS Edition)" ] +}