bats-mock
Mocking/stubbing library for BATS (Bash Automated Testing System)
Installation
Recommended installation is via git submodule. Assuming your project's bats
tests are in test
:
git submodule add https://github.com/jasonkarns/bats-mock test/helpers/mocksgit commit -am 'added bats-mock module'
then in test/test_helper.bash
:
load helpers/mocks/stub
sparse-checkout
That is all that's necessary to get the stub helpers into your project. However, as a submodule, it pulls in this entire repo. If you'd like only the minimum necessary files, you'll need to configure the submodule for sparse-checkout.
Enable sparse-checkout from the submodule directory:
cd test/helpers/mocksgit config core.sparsecheckout true
Then configure explictly list the files you wish to have checked out. From the root of your project:
echo stub.bash >> .git/modules/test/helpers/mocks/info/sparse-checkoutecho binstub >> .git/modules/test/helpers/mocks/info/sparse-checkout
Credits
Extracted from the ruby-build test suite. Many thanks to its author and contributors: Sam Stephenson and Mislav Marohnić.