diff --git a/spec/Task/Plugin/Filesystem/FileSpec.php b/spec/Task/Plugin/Filesystem/FileSpec.php index 3d37173..b87b35a 100644 --- a/spec/Task/Plugin/Filesystem/FileSpec.php +++ b/spec/Task/Plugin/Filesystem/FileSpec.php @@ -53,15 +53,25 @@ function it_should_write_content() expect(file_get_contents($this->path))->toBe('foo'); } - function it_should_write_file_content() + function it_should_write_new_file_content() + { + $src = vfsStream::url('tmp').'/src'; + + $src = new File($src); + $this->write('bar'); + + $this->read()->shouldReturn('bar'); + } + + function it_should_overwrite_file_content() { $src = vfsStream::url('tmp').'/src'; file_put_contents($src, 'foo'); $src = new File($src); - $this->write($src); + $this->write('bar'); - $this->read()->shouldReturn('foo'); + $this->read()->shouldReturn('bar'); } function it_should_append_content() diff --git a/src/Filesystem/File.php b/src/Filesystem/File.php index 5e10203..b810ba0 100644 --- a/src/Filesystem/File.php +++ b/src/Filesystem/File.php @@ -32,6 +32,7 @@ public function write($data) } $this->ftruncate(0); + $this->rewind(); $this->fwrite($data); return $this; }