diff --git a/src/spec b/src/spec index b2d1a8d..6798ee2 100644 --- a/src/spec +++ b/src/spec @@ -167,7 +167,9 @@ to() type "$assert" &>/dev/null \ || _bail "unknown expectation: \`$type'" $__spec_caller - $assert "$__spec_rexit" "$@" || fail "$expect_full" + $assert "$__spec_rexit" "$@" <<< "$__spec_result" \ + || fail "$expect_full" + __spec_caller= } diff --git a/test/test-spec b/test/test-spec index 5d84e6f..96c0a48 100644 --- a/test/test-spec +++ b/test/test-spec @@ -139,6 +139,20 @@ describe expect '; to succeed end + it pipes command stdout to expectation handler + expect test-run <<< ' + declare str=foo + _expect--chk() { test "$(cat)" == "$2"; } + + describe foo + it pipes command output + expect echo "$str" + to chk "$str" + end + end + '; to succeed + end + describe to it fails when missing assertion string