diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index 54c7440f05c7..2f9ea6c80195 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -24,15 +24,15 @@ def setup end def test_bad_connection - dir = "/tmp/should/_exist/" - FileUtils.mkdir_p dir - File.chmod(0x000, dir) - db_path = File.join(dir, "db/cant-be-created.db") - error = assert_raise ActiveRecord::NoDatabaseError do - connection = SQLite3Adapter.new(adapter: "sqlite3", database: db_path) - connection.drop_table "ex", if_exists: true + Dir.mktmpdir do |dir| + File.chmod(0x000, dir) + db_path = File.join(dir, "db/cant-be-created.db") + error = assert_raise ActiveRecord::NoDatabaseError do + connection = SQLite3Adapter.new(adapter: "sqlite3", database: db_path) + connection.drop_table "ex", if_exists: true + end + assert_kind_of ActiveRecord::ConnectionAdapters::NullPool, error.connection_pool end - assert_kind_of ActiveRecord::ConnectionAdapters::NullPool, error.connection_pool end def test_database_should_get_created_when_missing_parent_directories_for_database_path