eventualbuddha/fakefs — pull request #1 by eventualbuddha (2013-12-05 00:51:32+00:00)
Title: Fix Dir.foreach with relative paths.

`Dir#read` gets contents that are the full path (e.g. /path/to/file.txt) and then strips off the path of the directory (e.g. /path/to) before returning them (e.g. file.txt). This works fine when `Dir#path` is absolute, but not when it is relative. For example, this should print out "file.txt" but it was previously printing "/path/file.txt":

```ruby
FileUtils.mkdir_p("/path/to")
File.open("/path/to/file.txt", "w") {|f| f << '' }
Dir.chdir("/path") do
Dir.foreach("to") do |file|
puts file
end
end
```

The fix was to always store the normalized path as the `Dir` path when it is initialized. In addition I changed it to stop using the dubious `gsub` in favor of something that actually checks that it starts with the path.