@@ -9,18 +9,18 @@ function test_successful_assert_match_snapshot() {
99}
1010
1111function test_creates_a_snapshot() {
12- local snapshot_path=tests/unit/snapshots/assert_snapshot_test_sh.test_creates_a_snapshot.snapshot
12+ # shellcheck disable=SC2155
13+ local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_creates_a_snapshot.snapshot"
1314 local expected=$(( _ASSERTIONS_SNAPSHOT + 1 ))
1415
15- assert_file_not_exists $snapshot_path
16-
17- assert_match_snapshot " Expected snapshot"
16+ assert_file_not_exists " $snapshot_path "
17+ assert_match_snapshot " Expected snapshot" " $snapshot_path "
1818
1919 assert_same " $expected " " $_ASSERTIONS_SNAPSHOT "
20- assert_file_exists $snapshot_path
21- assert_same " Expected snapshot" " $( cat $snapshot_path ) "
20+ assert_file_exists " $snapshot_path "
21+ assert_same " Expected snapshot" " $( cat " $snapshot_path " ) "
2222
23- rm $snapshot_path
23+ rm -rf " $temp_dir "
2424}
2525
2626function test_unsuccessful_assert_match_snapshot() {
@@ -47,22 +47,20 @@ function test_successful_assert_match_snapshot_ignore_colors() {
4747 assert_empty " $( assert_match_snapshot_ignore_colors " $colored " ) "
4848}
4949
50+ # shellcheck disable=SC2155
5051function test_creates_a_snapshot_ignore_colors() {
51- local snapshot_path=tests/unit/snapshots/ assert_snapshot_test_sh.test_creates_a_snapshot_ignore_colors.snapshot
52+ local snapshot_path=" $( temp_dir ) / assert_snapshot_test_sh.test_creates_a_snapshot_ignore_colors.snapshot"
5253 local expected=$(( _ASSERTIONS_SNAPSHOT + 1 ))
5354
54- assert_file_not_exists $snapshot_path
55-
56- local colored
57- colored=$( printf ' \e[32mExpected\e[0m snapshot' )
58-
59- assert_match_snapshot_ignore_colors " $colored "
55+ assert_file_not_exists " $snapshot_path "
56+ local colored=$( printf ' \e[32mExpected\e[0m snapshot' )
57+ assert_match_snapshot_ignore_colors " $colored " " $snapshot_path "
6058
6159 assert_same " $expected " " $_ASSERTIONS_SNAPSHOT "
62- assert_file_exists $snapshot_path
63- assert_same " Expected snapshot" " $( cat $snapshot_path ) "
60+ assert_file_exists " $snapshot_path "
61+ assert_same " Expected snapshot" " $( cat " $snapshot_path " ) "
6462
65- rm $snapshot_path
63+ rm -rf " $temp_dir "
6664}
6765
6866function test_unsuccessful_assert_match_snapshot_ignore_colors() {
@@ -90,9 +88,8 @@ function test_assert_match_snapshot_with_placeholder() {
9088 skip " not supported on alpine" && return
9189 fi
9290
93- local temp_dir
94- temp_dir=$( mktemp -d)
95- local snapshot_path=" $temp_dir /assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot"
91+ # shellcheck disable=SC2155
92+ local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot"
9693 echo ' Run at ::ignore::' > " $snapshot_path "
9794
9895 assert_empty " $( assert_match_snapshot " Run at $( date) " " $snapshot_path " ) "
@@ -105,9 +102,8 @@ function test_assert_match_snapshot_with_custom_placeholder() {
105102 skip " not supported on alpine" && return
106103 fi
107104
108- local temp_dir
109- temp_dir=$( mktemp -d)
110- local snapshot_path=" $temp_dir /assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot"
105+ # shellcheck disable=SC2155
106+ local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot"
111107 echo ' Value __ANY__' > " $snapshot_path "
112108
113109 export BASHUNIT_SNAPSHOT_PLACEHOLDER=' __ANY__'
0 commit comments