From b4572d420b4b28dbb5bca889264ce2b081a8e5d0 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 9 May 2014 01:59:21 -0400 Subject: [PATCH] Expectation premise output now piped to expectation handler --- src/spec | 4 +++- test/test-spec | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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