From: Nikolai Weibull Date: 2009-10-02T22:00:10+09:00 Subject: Re: Config.datadir during testing On Oct 1, 8:12 pm, "nikolai.weib...@gmail.com" wrote: > How do I deal with Config.datadir during testing?  I don’t want it to > point to where the Gem will be, once it has been installed, but to the > ”data” directory in my current work directory. > > I figured that I’d override Config.datadir > > module Config >   def self.datadir(package) >     parts = File.expand_path('.').split(/[#{Regexp.escape > (File::SEPARATOR + File::ALT_SEPARATOR)}]/) >     until parts.empty? >       break if parts.last == package >     end >     return (package) if parts.empty? >     parts.push 'data', package >     File.join(*parts) >   end > end > > but the question is what I should replace with.  I first > figured I’d do > > module ConfigWrapper >   def self.datadir(package) >     parts = File.expand_path('.').split(/[#{Regexp.escape > (File::SEPARATOR + File::ALT_SEPARATOR)}]/) >     until parts.empty? >       break if parts.last == package >     end >     return super(package) if parts.empty? >     parts.push 'data', package >     File.join(*parts) >   end > end OK, I’m a fucking moron. That should be while last = parts.pop break if last == package end Still, it would be nice to see alternative solutions to this.