view README.md @ 2:078a17d15fa5

Support calling a spied command with arguments. `b.sh` was not compatible with calling a spied command with arguments. Example: my_test() { spy diff diff --brief test/a test/b ok "$(cat $T/spy.diff.exit)" = 0 } bricolage my_test This was not work. `diff` was complaining about 'illegal option'. This commit fix this.
author Jakukyo Friel <weakish@gmail.com>
date Sun, 29 Mar 2015 08:56:42 +0800
parents bce8021ad094
children 0798045f37b5
line wrap: on
line source

# Bricolage

Bricolage is an ultimately minimal testing library for UNIX Shell. It follows the idea of klud.js and gambiarra.lua

## Usage

	# include b.sh
	. b.sh

	# optionally define pass/fail handlers
	pass() {
		echo "PASS $*"
	}

	fail() {
		echo "FAIL $*"
	}

	# write your test functions
	mytest() {
		# inside use test assertions
		ok 1 -eq 1
		ok $FOO = "somevalue"
 		# mock/spy some commands
		spy ls
		# give fake command output
		echo "file.txt" > $T/spy.ls
		# use fake ls
		ls /some/dir
		# ensure that argument was passed correctly
		ok $(cat $T/spy.ls.args) = "/some/dir"
		# ensure that command return expected output
		ok $(cat $T/spy.ls.stdout) = "file.txt"
	}

	# run your tests
	bricolage mytest

	# cleanup
	rm -r $T

## License

Distributed under MIT license