@@ -52,7 +52,7 @@ function spy() {
5252 export " ${variable} _params_file" =" $params_file "
5353
5454 eval " function $command () {
55- echo \"\$ *\" > '$params_file '
55+ echo \"\$ *\" >> '$params_file '
5656 local _c=\$ (cat '$times_file ')
5757 _c=\$ ((_c+1))
5858 echo \"\$ _c\" > '$times_file '
@@ -86,14 +86,30 @@ function assert_have_been_called() {
8686function assert_have_been_called_with() {
8787 local expected=$1
8888 local command=$2
89+ local third_arg=" ${3:- } "
90+ local fourth_arg=" ${4:- } "
91+
92+ local index=" "
93+ local label=" "
94+ if [[ -n $third_arg && $third_arg =~ ^[0-9]+$ ]]; then
95+ index=$third_arg
96+ label=" ${fourth_arg:- $(helper:: normalize_test_function_name " ${FUNCNAME[1]} " )} "
97+ else
98+ label=" ${third_arg:- $(helper:: normalize_test_function_name " ${FUNCNAME[1]} " )} "
99+ index=" $fourth_arg "
100+ fi
101+
89102 local variable
90103 variable=" $( helper::normalize_variable_name " $command " ) "
91104 local file_var=" ${variable} _params_file"
92105 local params=" "
93106 if [[ -f " ${! file_var-} " ]]; then
94- params=$( cat " ${! file_var} " )
107+ if [[ -n $index ]]; then
108+ params=$( sed -n " ${index} p" " ${! file_var} " )
109+ else
110+ params=$( tail -n 1 " ${! file_var} " )
111+ fi
95112 fi
96- local label=" ${3:- $(helper:: normalize_test_function_name " ${FUNCNAME[1]} " )} "
97113
98114 if [[ " $expected " != " $params " ]]; then
99115 state::add_assertions_failed
0 commit comments