-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SugarUtils::File.atomic_write method
- Loading branch information
Showing
5 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Feature: Write to a file atomically | ||
|
||
Scenario: Write a file atomically | ||
When I run the following Ruby code: | ||
"""ruby | ||
require 'sugar_utils' | ||
puts SugarUtils::File.atomic_write('dir/test', 'foobar') | ||
""" | ||
Then the file named "dir/test" should contain exactly: | ||
""" | ||
foobar | ||
""" | ||
|
||
Scenario: Overwrite a file atomically | ||
Given a file named "dir/test" with "deadbeef" | ||
When I run the following Ruby code: | ||
"""ruby | ||
require 'sugar_utils' | ||
puts SugarUtils::File.atomic_write('dir/test', 'foobar') | ||
""" | ||
Then the file named "dir/test" should contain exactly: | ||
""" | ||
foobar | ||
""" | ||
|
||
# TODO: Fix the owner/group setting check | ||
Scenario: Overwrite a file and reset its permissions atomically | ||
Given a file named "dir/test" with "deadbeef" | ||
When I run the following Ruby code: | ||
"""ruby | ||
require 'sugar_utils' | ||
puts SugarUtils::File.atomic_write( | ||
'dir/test', | ||
'foobar', | ||
# owner: 'nobody', | ||
# group: 'nogroup', | ||
mode: 0o777 | ||
) | ||
""" | ||
Then the file named "dir/test" should contain exactly: | ||
""" | ||
foobar | ||
""" | ||
And the file named "dir/test" should have permissions "777" | ||
# And the file named "dir/test" should have owner "nobody" | ||
# And the file named "dir/test" should have group "nogroup" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters