Skip to content

Add ShellSpec and Bats test suites #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

25 changes: 25 additions & 0 deletions spec/git_flow_init_spec.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/git_flow_version.bats
Original file line number Diff line number Diff line change
@@ -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)" ]
}