Merge pull request #45965 from koic/enable_minitest_assert_raises_with_regexp_argument_cop

Enable `Minitest/AssertRaisesWithRegexpArgument` cop
This commit is contained in:
Ryuta Kamizono 2022-09-08 18:10:07 +09:00 committed by GitHub
commit e88005a875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View File

@ -435,7 +435,7 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-minitest (0.17.0)
rubocop-minitest (0.22.0)
rubocop (>= 0.90, < 2.0)
rubocop-packaging (0.5.1)
rubocop (>= 0.89, < 2.0)

View File

@ -108,11 +108,12 @@ module ActiveRecord
end
def test_bad_timeout
assert_raises(ActiveRecord::StatementInvalid, /TypeError/) do
exception = assert_raises(ActiveRecord::StatementInvalid) do
Base.sqlite3_connection(database: ":memory:",
adapter: "sqlite3",
timeout: "usa").connect!
end
assert_match("TypeError", exception.message)
end
# connection is OK with a nil timeout
@ -625,9 +626,10 @@ module ActiveRecord
readonly: true
conn.connect!
assert_raises(ActiveRecord::StatementInvalid, /SQLite3::ReadOnlyException/) do
exception = assert_raises(ActiveRecord::StatementInvalid) do
conn.execute("CREATE TABLE test(id integer)")
end
assert_match("SQLite3::ReadOnlyException", exception.message)
end
def test_strict_strings_by_default

View File

@ -304,13 +304,15 @@ module ApplicationTests
down_output = rails("db:migrate:down:#{namespace}", "VERSION=#{version}")
up_output = rails("db:migrate:up:#{namespace}", "VERSION=#{version}")
else
assert_raises RuntimeError, /You're using a multiple database application/ do
exception = assert_raises RuntimeError do
down_output = rails("db:migrate:down", "VERSION=#{version}")
end
assert_match("You're using a multiple database application", exception.message)
assert_raises RuntimeError, /You're using a multiple database application/ do
exception = assert_raises RuntimeError do
up_output = rails("db:migrate:up", "VERSION=#{version}")
end
assert_match("You're using a multiple database application", exception.message)
end
case namespace
@ -333,9 +335,10 @@ module ApplicationTests
if namespace
rollback_output = rails("db:rollback:#{namespace}")
else
assert_raises RuntimeError, /You're using a multiple database application/ do
exception = assert_raises RuntimeError do
rollback_output = rails("db:rollback")
end
assert_match("You're using a multiple database application", exception.message)
end
case namespace
@ -358,9 +361,10 @@ module ApplicationTests
if namespace
redo_output = rails("db:migrate:redo:#{namespace}")
else
assert_raises RuntimeError, /You're using a multiple database application/ do
exception = assert_raises RuntimeError do
redo_output = rails("db:migrate:redo")
end
assert_match("You're using a multiple database application", exception.message)
end
case namespace