defunkt/fakefs — pull request #226 by dekz (2014-03-13 05:50:49+00:00)
Title: initial Kernel open hijacking

It seems that FakeFS cannot handle open-uri on files.

```ruby
require 'open-uri'
require 'fakefs/safe'

describe 'fakefs and open-uri' do
before(:each) { FakeFS.activate! }
after(:each) { FakeFS.deactivate! }

it 'can read files' do
FileUtils.mkdir_p '/tmp'
File.open('/tmp/a.b', 'w+') { |f| f.puts 'test' }

data = File.read('/tmp/a.b')
expect(data).to match('test')
end

it 'can open-uri files' do
FileUtils.mkdir_p '/tmp'
File.open('/tmp/a.b', 'w+') { |f| f.puts 'test' }

begin
open('/tmp/a.b').read
rescue Exception => e
puts e
puts e.backtrace
raise e
end
expect(data).to match('test')
end
end

```

```
No such file or directory - /tmp/a.b
/Users/jacob/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/open-uri.rb:36:in `initialize'
/Users/jacob/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/open-uri.rb:36:in `open'
...
Failures:

1) fakefs and open-uri can open-uri files
Failure/Error: open('/tmp/a.b').read
Errno::ENOENT:
No such file or directory - /tmp/a.b
# ./test_spec.rb:20:in `block (2 levels) in '

Finished in 0.0035 seconds
2 examples, 1 failure
```

This [issue](https://github.com/defunkt/fakefs/issues/22) is related. `Kernel#open` is monkey patched by `open-uri` but it eventually fails on the original implementation being called.