Dir.pwd and Dir.getwd
This commit is contained in:
parent
9fb29f122d
commit
506a33fed4
@ -16,5 +16,13 @@ module FakeFS
|
|||||||
def self.chdir(dir, &blk)
|
def self.chdir(dir, &blk)
|
||||||
FileSystem.chdir(dir, &blk)
|
FileSystem.chdir(dir, &blk)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.pwd
|
||||||
|
FileSystem.current_dir.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
alias_method :getwd, :pwd
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -312,6 +312,20 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
assert_equal ['foo'], FileSystem.current_dir.keys
|
assert_equal ['foo'], FileSystem.current_dir.keys
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_current_dir_reflected_by_pwd
|
||||||
|
FileUtils.mkdir_p '/path'
|
||||||
|
Dir.chdir('/path')
|
||||||
|
|
||||||
|
assert_equal '/path', Dir.pwd
|
||||||
|
assert_equal '/path', Dir.getwd
|
||||||
|
|
||||||
|
FileUtils.mkdir_p 'subdir'
|
||||||
|
Dir.chdir('subdir')
|
||||||
|
|
||||||
|
assert_equal '/path/subdir', Dir.pwd
|
||||||
|
assert_equal '/path/subdir', Dir.getwd
|
||||||
|
end
|
||||||
|
|
||||||
def test_file_open_defaults_to_read
|
def test_file_open_defaults_to_read
|
||||||
File.open('foo','w'){|f| f.write 'bar' }
|
File.open('foo','w'){|f| f.write 'bar' }
|
||||||
assert_equal 'bar', File.open('foo'){|f| f.read }
|
assert_equal 'bar', File.open('foo'){|f| f.read }
|
||||||
|
Loading…
Reference in New Issue
Block a user