mirror of
https://github.com/jimeh/stub.sh.git
synced 2026-02-19 13:46:40 +00:00
Ensure stub can be used multiple times on the same command
Ensures that the original bash function is preserved even if it is stubbed multiple times before a restore.
This commit is contained in:
@@ -43,5 +43,17 @@ restore "my-name-is"
|
||||
assert "my-name-is Edward Elric" "My name is Edward Elric."
|
||||
|
||||
|
||||
# Stubbing the same function multiple times and then restoring it.
|
||||
my-name-is() { echo "My name is $@."; }
|
||||
stub "my-name-is"
|
||||
assert "my-name-is Edward Elric" ""
|
||||
stub "my-name-is" stdout
|
||||
assert "my-name-is Edward Elric" "my-name-is stub: Edward Elric"
|
||||
|
||||
restore "my-name-is"
|
||||
assert "my-name-is Edward Elric" "My name is Edward Elric."
|
||||
|
||||
|
||||
|
||||
# End of tests.
|
||||
assert_end "restore()"
|
||||
|
||||
Reference in New Issue
Block a user