Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

1.2 - Better Support arguments with Whitespace

Compare
Choose a tag to compare
@ckstettler ckstettler released this 16 Oct 12:34
9e44da7

Overview

1.1 lacked support of quoted arguments when defining expectations and as a result it also introduced defects when using the partial mocking capability. 1.2 allows argument matchers to contain white space and supports the full range of match capabilities.

Compatibility

This update introduced non-compatibility when quoted args were previously used. Because of that I have introduced a new environment variable that will allow backward compatibility.

If you export SHELLMOCK_V1_COMPATIBILITY then you will get pre-1.2 behavior. The variable can be defined globally to cover all test cases or on a test case by test case basis.

Caveats

Because the shell itself eats the quotes, shellmock can not tell the difference between a single quote or a double quote so shellmock as opted to normalize and represent quoted arguments as double quotes. Therefore when verifying arguments, you should use the double-quote.

Additional samples were added to sample.sh and a new section in the read me covers the use of single and double quoted args.

Changes

  • README.adoc - Cleaned up the documentation and added new examples and section on whitespace in parameters.
  • shellmock - Added new feature to support whitespace.
  • sample.bats - Added examples for test cases with quoted args including partial mocks.
  • shellmock.bats - Added additional coverage for the various matching capabilities.