From 4bd78884a96300aff91f98e19145684cfd18ebb2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 4 Dec 2009 05:02:48 -0500 Subject: [PATCH] Make verify.rb more dynamic. Check for both class and instance methods of: * RealFile * RealFile::Stat * RealFileUtils * RealDir * RealFileTest --- test/verify.rb | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/test/verify.rb b/test/verify.rb index 46c2f67..52a4c10 100644 --- a/test/verify.rb +++ b/test/verify.rb @@ -7,29 +7,25 @@ require "test_helper" class FakeFSVerifierTest < Test::Unit::TestCase - def setup - FakeFS.activate! - end + class_mapping = { + RealFile => FakeFS::File, + RealFile::Stat => FakeFS::File::Stat, + RealFileUtils => FakeFS::FileUtils, + RealDir => FakeFS::Dir, + RealFileTest => FakeFS::FileTest + } - def teardown - FakeFS.deactivate! - end - - (RealFile.methods - Class.new.methods).each do |name| - define_method("test #{name} class method") do - assert File.respond_to?(name), "File.#{name} not implemented" + class_mapping.each do |real_class, fake_class| + real_class.methods.each do |method| + define_method "test #{method} class method" do + assert fake_class.respond_to?(method), "#{fake_class}.#{method} not implemented" + end end - end - (RealFile.instance_methods - Enumerable.instance_methods).each do |name| - define_method("test #{name} instance method") do - assert File.instance_methods.include?(name), "File##{name} not implemented" - 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" + real_class.instance_methods.each do |method| + define_method("test #{method} instance method") do + assert fake_class.instance_methods.include?(method), "#{fake_class}##{name} not implemented" + end end end end