Skip to content

Commit cc634ea

Browse files
committed
Check exception message explicitely
Current minitest only checks if the raised exception is of the same type or an instance of the given type. It does not compare its message against the regexp. As it returns the Exception we simply assert the message manually. Closes #493
1 parent fe39c55 commit cc634ea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/commands_on_value_types_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ def test_migrate
101101
redis_mock(:migrate => lambda { |*args| args }) do |redis|
102102
options = { :host => "127.0.0.1", :port => 1234 }
103103

104-
assert_raise(RuntimeError, /host not specified/) do
104+
ex = assert_raise(RuntimeError) do
105105
redis.migrate("foo", options.reject { |key, _| key == :host })
106106
end
107+
assert ex.message =~ /host not specified/
107108

108-
assert_raise(RuntimeError, /port not specified/) do
109+
ex = assert_raise(RuntimeError) do
109110
redis.migrate("foo", options.reject { |key, _| key == :port })
110111
end
112+
assert ex.message =~ /port not specified/
111113

112114
default_db = redis.client.db.to_i
113115
default_timeout = redis.client.timeout.to_i

0 commit comments

Comments
 (0)