Skip to content

Commit fd6f76c

Browse files
committed
config: relax test assertions against error messages
Test that the error message contains the necessary text instead of the exact match. Exceptions raised by ossl_raise() may carry additional context information in the message.
1 parent db633c5 commit fd6f76c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

test/openssl/test_config.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,19 @@ def test_s_parse_format
9191
assert_equal('123baz456bar798', c['dollar']['qux'])
9292
assert_equal('123baz456bar798.123baz456bar798', c['dollar']['quxx'])
9393

94-
excn = assert_raise(OpenSSL::ConfigError) do
94+
assert_raise_with_message(OpenSSL::ConfigError, /error in line 1: variable has no value/) do
9595
OpenSSL::Config.parse("foo = $bar")
9696
end
97-
assert_equal("error in line 1: variable has no value", excn.message)
9897

99-
excn = assert_raise(OpenSSL::ConfigError) do
98+
assert_raise_with_message(OpenSSL::ConfigError, /error in line 1: no close brace/) do
10099
OpenSSL::Config.parse("foo = $(bar")
101100
end
102-
assert_equal("error in line 1: no close brace", excn.message)
103101

104-
excn = assert_raise(OpenSSL::ConfigError) do
102+
assert_raise_with_message(OpenSSL::ConfigError, /error in line 1: missing equal sign/) do
105103
OpenSSL::Config.parse("f o =b ar # no space in key")
106104
end
107-
assert_equal("error in line 1: missing equal sign", excn.message)
108105

109-
excn = assert_raise(OpenSSL::ConfigError) do
106+
assert_raise_with_message(OpenSSL::ConfigError, /error in line 7: missing close square bracket/) do
110107
OpenSSL::Config.parse(<<__EOC__)
111108
# comment 1 # comments
112109
@@ -117,7 +114,6 @@ def test_s_parse_format
117114
[third # section not terminated
118115
__EOC__
119116
end
120-
assert_equal("error in line 7: missing close square bracket", excn.message)
121117
end
122118

123119
def test_s_parse_include

0 commit comments

Comments
 (0)