Make verify.rb more dynamic. Check for both class and instance methods of:

* RealFile
  * RealFile::Stat
  * RealFileUtils
  * RealDir
  * RealFileTest
This commit is contained in:
Scott Taylor 2009-12-04 05:02:48 -05:00
parent 522976f09c
commit 4bd78884a9

View File

@ -7,29 +7,25 @@
require "test_helper" require "test_helper"
class FakeFSVerifierTest < Test::Unit::TestCase class FakeFSVerifierTest < Test::Unit::TestCase
def setup class_mapping = {
FakeFS.activate! RealFile => FakeFS::File,
end RealFile::Stat => FakeFS::File::Stat,
RealFileUtils => FakeFS::FileUtils,
RealDir => FakeFS::Dir,
RealFileTest => FakeFS::FileTest
}
def teardown class_mapping.each do |real_class, fake_class|
FakeFS.deactivate! real_class.methods.each do |method|
end define_method "test #{method} class method" do
assert fake_class.respond_to?(method), "#{fake_class}.#{method} not implemented"
(RealFile.methods - Class.new.methods).each do |name| end
define_method("test #{name} class method") do
assert File.respond_to?(name), "File.#{name} not implemented"
end end
end
(RealFile.instance_methods - Enumerable.instance_methods).each do |name| real_class.instance_methods.each do |method|
define_method("test #{name} instance method") do define_method("test #{method} instance method") do
assert File.instance_methods.include?(name), "File##{name} not implemented" assert fake_class.instance_methods.include?(method), "#{fake_class}##{name} not implemented"
end end
end
(RealFileUtils.methods - Class.new.methods).each do |name|
define_method("test #{name} module method") do
assert FileUtils.respond_to?(name), "FileUtils.#{name} not implemented"
end end
end end
end end