<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -108,7 +108,7 @@ module FakeFS
       @file = FileSystem.find(path)
       @open = true
 
-      check_file_existence! if !file_creation_mode?
+      file_creation_mode? ? create_missing_file : check_file_existence!
     end
 
     def close
@@ -134,10 +134,7 @@ module FakeFS
       raise IOError, 'closed stream' unless @open
       raise IOError, 'not open for writing' if read_only?
 
-      if !File.exists?(@path)
-        @file = FileSystem.add(path, FakeFile.new)
-      end
-
+      create_missing_file
       @file.content += content
     end
     alias_method :print, :write
@@ -170,5 +167,11 @@ module FakeFS
         raise ArgumentError, &quot;illegal access mode #{mode}&quot;
       end
     end
+
+    def create_missing_file
+      if !File.exists?(@path)
+        @file = FileSystem.add(path, FakeFile.new)
+      end
+    end
   end
 end</diff>
      <filename>lib/fakefs/file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -126,6 +126,26 @@ class FakeFSTest &lt; Test::Unit::TestCase
     end
   end
 
+  def test_creates_files_in_write_only_mode
+    File.open(&quot;foo&quot;, &quot;w&quot;)
+    assert File.exists?(&quot;foo&quot;)
+  end
+
+  def test_creates_files_in_read_write_truncate_mode
+    File.open(&quot;foo&quot;, &quot;w+&quot;)
+    assert File.exists?(&quot;foo&quot;)
+  end
+
+  def test_creates_files_in_append_write_only
+    File.open(&quot;foo&quot;, &quot;a&quot;)
+    assert File.exists?(&quot;foo&quot;)
+  end
+
+  def test_creates_files_in_append_read_write
+    File.open(&quot;foo&quot;, &quot;a+&quot;)
+    assert File.exists?(&quot;foo&quot;)
+  end
+
   def test_can_read_files_once_written
     path = '/path/to/file.txt'
     File.open(path, 'w') do |f|</diff>
      <filename>test/fakefs_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>17e2e470273658cd0f22e652b17bee30fda8c200</id>
    </parent>
  </parents>
  <author>
    <name>Scott Taylor</name>
    <email>scott@railsnewbie.com</email>
  </author>
  <url>http://github.com/jyurek/fakefs/commit/e3446636e50bd96019f787329b297e7a33da96a9</url>
  <id>e3446636e50bd96019f787329b297e7a33da96a9</id>
  <committed-date>2009-09-30T23:46:00-07:00</committed-date>
  <authored-date>2009-09-30T00:20:59-07:00</authored-date>
  <message>Create files in w, w+, a, and a+ modes when calling File.new and the file is missing.</message>
  <tree>f5a182c147643ef574c7d2303d2870e195f38ad3</tree>
  <committer>
    <name>Scott Taylor</name>
    <email>scott@railsnewbie.com</email>
  </committer>
</commit>
