forked from jimeh/stub.sh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change behavior of stub_called_times
It now only ever returns the the number of times the stub has been called. To assert if it has been called exactly X number of times, use `stub_called_exact_times` instead.
- Loading branch information
Showing
4 changed files
with
51 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /usr/bin/env bash | ||
source "test-helper.sh" | ||
|
||
# | ||
# stub_called_exactly_times() tests. | ||
# | ||
|
||
# Setup. | ||
stub "uname" | ||
uname | ||
uname -r | ||
|
||
|
||
# Returns 0 when stub called exactly given number of times. | ||
assert_raises 'stub_called_exactly_times "uname" 2' 0 | ||
|
||
# Returns 1 when stub has not been called the exact given number of times. | ||
assert_raises 'stub_called_exactly_times "uname" 4' 1 | ||
assert_raises 'stub_called_exactly_times "uname" 3' 1 | ||
assert_raises 'stub_called_exactly_times "uname" 1' 1 | ||
assert_raises 'stub_called_exactly_times "uname" 0' 1 | ||
|
||
# Behaves as if stub has not been called when the stub doesn't exist. | ||
assert_raises 'stub_called_exactly_times "top" 0' 0 | ||
assert_raises 'stub_called_exactly_times "top" 1' 1 | ||
|
||
# Teardown. | ||
restore "uname" | ||
|
||
|
||
# End of tests. | ||
assert_end "stub_called_times()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters