diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 89db923..2332c0b 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -1,9 +1,9 @@ require 'fileutils' require 'pathname' require 'fakefs/base' -require 'fakefs/mock/file' -require 'fakefs/mock/dir' -require 'fakefs/mock/symlink' +require 'fakefs/fake/file' +require 'fakefs/fake/dir' +require 'fakefs/fake/symlink' require 'fakefs/file_system' require 'fakefs/fileutils' require 'fakefs/file' diff --git a/lib/fakefs/mock/dir.rb b/lib/fakefs/fake/dir.rb similarity index 87% rename from lib/fakefs/mock/dir.rb rename to lib/fakefs/fake/dir.rb index 1c31fa3..5ca8ca1 100644 --- a/lib/fakefs/mock/dir.rb +++ b/lib/fakefs/fake/dir.rb @@ -1,5 +1,5 @@ module FakeFS - class MockDir < Hash + class FakeDir < Hash attr_accessor :name, :parent def initialize(name = nil, parent = nil) @@ -12,7 +12,7 @@ module FakeFS end def inspect - "(MockDir name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{size})" + "(FakeDir name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{size})" end def clone(parent = nil) @@ -34,4 +34,4 @@ module FakeFS end end end -end \ No newline at end of file +end diff --git a/lib/fakefs/mock/file.rb b/lib/fakefs/fake/file.rb similarity index 83% rename from lib/fakefs/mock/file.rb rename to lib/fakefs/fake/file.rb index 2283ac4..c8ce6df 100644 --- a/lib/fakefs/mock/file.rb +++ b/lib/fakefs/fake/file.rb @@ -1,5 +1,5 @@ module FakeFS - class MockFile + class FakeFile attr_accessor :name, :parent, :content def initialize(name = nil, parent = nil) @@ -19,11 +19,11 @@ module FakeFS end def inspect - "(MockFile name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{content.size})" + "(FakeFile name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{content.size})" end def to_s File.join(parent.to_s, name) end end -end \ No newline at end of file +end diff --git a/lib/fakefs/mock/symlink.rb b/lib/fakefs/fake/symlink.rb similarity index 93% rename from lib/fakefs/mock/symlink.rb rename to lib/fakefs/fake/symlink.rb index 2182882..ef78c5e 100644 --- a/lib/fakefs/mock/symlink.rb +++ b/lib/fakefs/fake/symlink.rb @@ -1,5 +1,5 @@ module FakeFS - class MockSymlink + class FakeSymlink attr_accessor :name, :target alias_method :to_s, :name @@ -19,4 +19,4 @@ module FakeFS entry.send(*args, &block) end end -end \ No newline at end of file +end diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 8fc9259..b97e301 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -20,27 +20,27 @@ module FakeFS def self.directory?(path) if path.respond_to? :entry - path.entry.is_a? MockDir + path.entry.is_a? FakeDir else result = FileSystem.find(path) - result ? result.entry.is_a?(MockDir) : false + result ? result.entry.is_a?(FakeDir) : false end end def self.symlink?(path) if path.respond_to? :entry - path.is_a? MockSymlink + path.is_a? FakeSymlink else - FileSystem.find(path).is_a? MockSymlink + FileSystem.find(path).is_a? FakeSymlink end end def self.file?(path) if path.respond_to? :entry - path.entry.is_a? MockFile + path.entry.is_a? FakeFile else result = FileSystem.find(path) - result ? result.entry.is_a?(MockFile) : false + result ? result.entry.is_a?(FakeFile) : false end end @@ -111,7 +111,7 @@ module FakeFS raise IOError.new('closed stream') unless @open if !File.exists?(@path) - @file = FileSystem.add(path, MockFile.new) + @file = FileSystem.add(path, FakeFile.new) end @file.content += content diff --git a/lib/fakefs/file_system.rb b/lib/fakefs/file_system.rb index 742e2cb..2f2f357 100644 --- a/lib/fakefs/file_system.rb +++ b/lib/fakefs/file_system.rb @@ -7,7 +7,7 @@ module FakeFS end def fs - @fs ||= MockDir.new('.') + @fs ||= FakeDir.new('.') end def clear @@ -34,11 +34,11 @@ module FakeFS end end - def add(path, object=MockDir.new) + def add(path, object=FakeDir.new) parts = path_parts(normalize_path(path)) d = parts[0...-1].inject(fs) do |dir, part| - dir[part] ||= MockDir.new(part, dir) + dir[part] ||= FakeDir.new(part, dir) end object.name = parts.last @@ -102,4 +102,4 @@ module FakeFS find(normalize_path('.')) end end -end \ No newline at end of file +end diff --git a/lib/fakefs/fileutils.rb b/lib/fakefs/fileutils.rb index d3b6a45..d9c182c 100644 --- a/lib/fakefs/fileutils.rb +++ b/lib/fakefs/fileutils.rb @@ -3,7 +3,7 @@ module FakeFS extend self def mkdir_p(path) - FileSystem.add(path, MockDir.new) + FileSystem.add(path, FakeDir.new) end def rm(path) @@ -14,7 +14,7 @@ module FakeFS def ln_s(target, path) raise Errno::EEXIST, path if FileSystem.find(path) - FileSystem.add(path, MockSymlink.new(target)) + FileSystem.add(path, FakeSymlink.new(target)) end def cp(src, dest) @@ -93,7 +93,7 @@ module FakeFS directory = File.dirname(f) # FIXME this explicit check for '.' shouldn't need to happen if File.exists?(directory) || directory == '.' - FileSystem.add(f, MockFile.new) + FileSystem.add(f, FakeFile.new) else raise Errno::ENOENT, f end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index aee941f..2304a5b 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -23,7 +23,7 @@ class FakeFSTest < Test::Unit::TestCase def test_can_create_directories FileUtils.mkdir_p("/path/to/dir") - assert_kind_of MockDir, FileSystem.fs['path']['to']['dir'] + assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir'] end def test_knows_directories_exist @@ -57,7 +57,7 @@ class FakeFSTest < Test::Unit::TestCase def test_can_create_symlinks FileUtils.mkdir_p(target = "/path/to/target") FileUtils.ln_s(target, "/path/to/link") - assert_kind_of MockSymlink, FileSystem.fs['path']['to']['link'] + assert_kind_of FakeSymlink, FileSystem.fs['path']['to']['link'] assert_raises(Errno::EEXIST) { FileUtils.ln_s(target, '/path/to/link')