spec/utility_spec.rb in palimpsest-0.0.1 vs spec/utility_spec.rb in palimpsest-0.1.0
- old
+ new
@@ -44,13 +44,24 @@
end
describe "write" do
let(:file) { double File }
+ let(:mtime) { Time.now }
- it "writes to file" do
+ before :each do
allow(File).to receive(:open).with('path/to/file', 'w').and_yield(file)
+ end
+
+ it "writes to file" do
expect(file).to receive(:write).with('data')
Palimpsest::Utility.write 'data', 'path/to/file'
+ end
+
+ it "can preserve atime and mtime" do
+ allow(file).to receive(:write)
+ allow(File).to receive(:mtime).with('path/to/file').and_return(mtime)
+ expect(File).to receive(:utime).with(mtime, mtime, 'path/to/file')
+ Palimpsest::Utility.write 'data', 'path/to/file', preserve: true
end
end
end