Skip to content

Commit cad6157

Browse files
committed
ztombol's assert_success only checks status
In order to asser the output as well, we have to explicitly assert_output
1 parent a49ef14 commit cad6157

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

test/nodenv-package-json-engine.bats

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,81 @@ load test_helper
66
in_package_for_engine 4.2.1
77

88
run nodenv version
9-
assert_success '4.2.1 (set by package-json-engine matching 4.2.1)'
9+
assert_success
10+
assert_output '4.2.1 (set by package-json-engine matching 4.2.1)'
1011
}
1112

1213
@test 'Prefers the greatest installed version matching a range' {
1314
in_package_for_engine '^4.0.0'
1415

1516
run nodenv version
16-
assert_success '4.2.1 (set by package-json-engine matching ^4.0.0)'
17+
assert_success
18+
assert_output '4.2.1 (set by package-json-engine matching ^4.0.0)'
1719
}
1820

1921
@test 'Ignores non-matching installed versions' {
2022
in_package_for_engine '^1.0.0'
2123

2224
run nodenv version
2325
# note the command completes successfully
24-
assert_success "package-json-engine: version satisfying \`^1.0.0' not installed
25-
(set by package-json-engine matching ^1.0.0)"
26+
assert_success
27+
assert_output <<-MSG
28+
package-json-engine: version satisfying \`^1.0.0' not installed
29+
(set by package-json-engine matching ^1.0.0)
30+
MSG
2631
}
2732

2833
@test 'Prefers nodenv-local over package.json' {
2934
in_package_for_engine 4.2.1
3035
nodenv local 5.0.0
3136

3237
run nodenv version
33-
assert_success "5.0.0 (set by $PWD/.node-version)"
38+
assert_success
39+
assert_output "5.0.0 (set by $PWD/.node-version)"
3440
}
3541

3642
@test 'Prefers nodenv-shell over package.json' {
3743
in_package_for_engine 4.2.1
3844

3945
NODENV_VERSION=5.0.0 run nodenv version
40-
assert_success "5.0.0 (set by NODENV_VERSION environment variable)"
46+
assert_success
47+
assert_output "5.0.0 (set by NODENV_VERSION environment variable)"
4148
}
4249

4350
@test 'Prefers package.json over nodenv-global' {
4451
in_package_for_engine 4.2.1
4552
nodenv global 5.0.0
4653

4754
run nodenv version-name
48-
assert_success '4.2.1'
55+
assert_success
56+
assert_output '4.2.1'
4957
}
5058

5159
@test 'Is not confused by nodenv-shell shadowing nodenv-global' {
5260
in_package_for_engine 4.2.1
5361
nodenv global 5.0.0
5462

5563
NODENV_VERSION=5.0.0 run nodenv version
56-
assert_success "5.0.0 (set by NODENV_VERSION environment variable)"
64+
assert_success
65+
assert_output "5.0.0 (set by NODENV_VERSION environment variable)"
5766
}
5867

5968
@test 'Does not match arbitrary "node" key in package.json' {
6069
in_package_with_babel_env
6170

6271
run nodenv version-name
6372

64-
assert_success 'system'
73+
assert_success
74+
assert_output 'system'
6575
}
6676

6777
@test 'Handles missing package.json' {
6878
in_example_package
6979

7080
run nodenv version-name
7181

72-
assert_success 'system'
82+
assert_success
83+
assert_output 'system'
7384
}
7485

7586
@test 'Does not fail with unreadable package.json' {
@@ -79,7 +90,8 @@ load test_helper
7990

8091
run nodenv version-name
8192

82-
assert_success 'system'
93+
assert_success
94+
assert_output 'system'
8395
}
8496

8597
@test 'Does not fail with non-file package.json' {
@@ -88,7 +100,8 @@ load test_helper
88100

89101
run nodenv version-name
90102

91-
assert_success 'system'
103+
assert_success
104+
assert_output 'system'
92105
}
93106

94107
@test 'Does not fail with empty or malformed package.json' {
@@ -97,17 +110,20 @@ load test_helper
97110
# empty
98111
touch package.json
99112
run nodenv version-name
100-
assert_success 'system'
113+
assert_success
114+
assert_output 'system'
101115

102116
# non json
103117
echo "foo" > package.json
104118
run nodenv version-name
105-
assert_success 'system'
119+
assert_success
120+
assert_output 'system'
106121

107122
# malformed
108123
echo "{" > package.json
109124
run nodenv version-name
110-
assert_success 'system'
125+
assert_success
126+
assert_output 'system'
111127
}
112128

113129
@test 'Handles multiple occurrences of "node" key' {
@@ -128,5 +144,6 @@ load test_helper
128144
JSON
129145

130146
run nodenv version-name
131-
assert_success '4.2.1'
147+
assert_success
148+
assert_output '4.2.1'
132149
}

0 commit comments

Comments
 (0)