@@ -65,3 +65,43 @@ function test_unsuccessful_spy_called_times() {
6565 " $( console_results::print_failed_test " Unsuccessful spy called times" " ps" " to has been called" " 1 times" ) " \
6666 " $( assert_have_been_called_times 1 ps) "
6767}
68+
69+ function test_successful_spy_with_source_function() {
70+ # shellcheck source=/dev/null
71+ source ./fixtures/fake_function_to_spy.sh
72+ spy function_to_be_spied_on
73+
74+ function_to_be_spied_on
75+
76+ assert_have_been_called function_to_be_spied_on
77+ }
78+
79+ function test_unsuccessful_spy_with_source_function_have_been_called() {
80+ # shellcheck source=/dev/null
81+ source ./fixtures/fake_function_to_spy.sh
82+ spy function_to_be_spied_on
83+
84+ function_to_be_spied_on
85+ function_to_be_spied_on
86+
87+ assert_same\
88+ " $( console_results::print_failed_test \
89+ " Unsuccessful spy with source function have been called" \
90+ " function_to_be_spied_on" \
91+ " to has been called" \
92+ " 1 times" ) " \
93+ " $( assert_have_been_called_times 1 function_to_be_spied_on) "
94+ }
95+
96+
97+ function test_successful_spy_called_times_with_source() {
98+ # shellcheck source=/dev/null
99+ source ./fixtures/fake_function_to_spy.sh
100+ spy function_to_be_spied_on
101+
102+ function_to_be_spied_on
103+ function_to_be_spied_on
104+
105+ assert_have_been_called_times 2 function_to_be_spied_on
106+ }
107+
0 commit comments