From: Rodrigo Rosenfeld Rosas Date: 2013-08-17T09:10:26-03:00 Subject: [ruby-core:56687] Re: [ruby-trunk - Feature #8781] Use require_relative() instead of require() if possible Em 17-08-2013 01:16, Aaron Patterson escreveu: > ... >> I don't really think using require to allow such hacks is a good >> enough reason to favor require instead of require_relative... After >> all, Ruby already allows you to override code by monkey patching. >> Why would you need to override a full file? > Simply requiring a file will execute code. There are times (especially > in tests) where you do not want ANY of the code to be executed (maybe it > connects to a database, or network, etc). Now I finally understand how people are using this trick. I believe this is mostly used for mocking domain classes (Rails models, for instance) when using ActiveRecord or Sequel, given their metaprogramming tricks on initialization to fetch the tables meta-data. But I don't see how this ticket would affect such environments. If I understand correctly, what Koichi proposed is to replace require with require_relative on Ruby stdlibs and core classes only. Do you see any reason you'd like to execute those files? I believe they won't touch any database or network so they shouldn't slow down any tests, right? Cheers, Rodrigo.