Added File.extname and FileUtils.rmdir

This commit is contained in:
Myles Eftos 2009-09-14 01:41:00 +08:00
parent 1403c5b421
commit a926ebf1c5
5 changed files with 25 additions and 2 deletions

View File

@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{fakefs}
s.version = "0.1.3"
s.version = "0.1.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Chris Wanstrath"]

View File

@ -2,6 +2,10 @@ module FakeFS
class File
PATH_SEPARATOR = '/'
def self.extname(path)
RealFile.extname(path)
end
def self.join(*parts)
parts * PATH_SEPARATOR
end

View File

@ -6,6 +6,14 @@ module FakeFS
FileSystem.add(path, FakeDir.new)
end
def rmdir(list, options = {})
list = [ list ] unless list.is_a?(Array)
list.each do |l|
raise Errno::ENOENT, l unless FileSystem.find(l)
rm(l)
end
end
def rm(path)
FileSystem.delete(path)
end

View File

@ -1,6 +1,6 @@
module FakeFS
module Version
VERSION = "0.1.3"
VERSION = "0.1.4"
def self.to_s
VERSION

View File

@ -25,6 +25,13 @@ class FakeFSTest < Test::Unit::TestCase
FileUtils.mkdir_p("/path/to/dir")
assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir']
end
def test_can_delete_directories
FileUtils.mkdir_p("/path/to/dir")
FileUtils.rmdir("/path/to/dir")
assert File.exists?("/path/to/")
assert File.exists?("/path/to/dir") == false
end
def test_knows_directories_exist
FileUtils.mkdir_p(path = "/path/to/dir")
@ -532,6 +539,10 @@ class FakeFSTest < Test::Unit::TestCase
}
end
def test_extname
assert File.extname("test.doc") == ".doc"
end
# Directory tests
def test_new_directory
FileUtils.mkdir_p('/this/path/should/be/here')