How do I deal with Config.datadir during testing?  I don=92t want it to
point to where the Gem will be, once it has been installed, but to the
=94data=94 directory in my current work directory.

I figured that I=92d override Config.datadir

module Config
  def self.datadir(package)
    parts =3D File.expand_path('.').split(/[#{Regexp.escape
(File::SEPARATOR + File::ALT_SEPARATOR)}]/)
    until parts.empty?
      break if parts.last =3D=3D package
    end
    return <what>(package) if parts.empty?
    parts.push 'data', package
    File.join(*parts)
  end
end

but the question is what I should replace <what> with.  I first
figured I=92d do

module ConfigWrapper
  def self.datadir(package)
    parts =3D File.expand_path('.').split(/[#{Regexp.escape
(File::SEPARATOR + File::ALT_SEPARATOR)}]/)
    until parts.empty?
      break if parts.last =3D=3D package
    end
    return super(package) if parts.empty?
    parts.push 'data', package
    File.join(*parts)
  end
end

Config.extend(ConfigWrapper),

but that won=92t work, as that won=92t put ConfigWrapper in the right
place in the call chain (obvious, in retrospect).  So I figured I=92d do

module Config
  class << self
    alias old_datadir datadir
  end
  def self.datadir(package)
    parts =3D File.expand_path('.').split(/[#{Regexp.escape
(File::SEPARATOR + File::ALT_SEPARATOR)}]/)
    until parts.empty?
      break if parts.last =3D=3D package
    end
    return old_datadir(package) if parts.empty?
    parts.push 'data', package
    File.join(*parts)
  end
end

but that doesn=92t work, as old_datadir will simply point to the current
Config.datadir implementation, thus resulting in an infinite loop.

I see no way around it.

What should I do?

(I=92d be very pleased if I didn=92t have to modify Config.datadir, so if
there=92s a solution without it that would be nice.  I would also like
to see a solution to the problem of overriding a module method.)

Thanks!