Skip to content

Commit

Permalink
[ruby/openssl] config: relax test assertions against error messages
Browse files Browse the repository at this point in the history
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.

ruby/openssl@fd6f76c0d3
  • Loading branch information
rhenium committed Aug 16, 2023
1 parent 01d368e commit 382b42b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/openssl/test_config.rb
Expand Up @@ -91,22 +91,19 @@ def test_s_parse_format
assert_equal('123baz456bar798', c['dollar']['qux'])
assert_equal('123baz456bar798.123baz456bar798', c['dollar']['quxx'])

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

excn = assert_raise(OpenSSL::ConfigError) do
assert_raise_with_message(OpenSSL::ConfigError, /error in line 1: no close brace/) do
OpenSSL::Config.parse("foo = $(bar")
end
assert_equal("error in line 1: no close brace", excn.message)

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

excn = assert_raise(OpenSSL::ConfigError) do
assert_raise_with_message(OpenSSL::ConfigError, /error in line 7: missing close square bracket/) do
OpenSSL::Config.parse(<<__EOC__)
# comment 1 # comments
Expand All @@ -117,7 +114,6 @@ def test_s_parse_format
[third # section not terminated
__EOC__
end
assert_equal("error in line 7: missing close square bracket", excn.message)
end

def test_s_parse_include
Expand Down

0 comments on commit 382b42b

Please sign in to comment.