mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
Replace the Swift site generator with a Ruby and Phlex implementation. Loads site and projects from TOML, derive site metadata from posts. Migrate from make to bake and add standardrb and code coverage tasks. Update CI and docs to match the new workflow, and remove unused assets/dependencies plus obsolete tooling.
25 lines
837 B
Ruby
25 lines
837 B
Ruby
require "test_helper"
|
|
require "tmpdir"
|
|
|
|
class Pressa::Utils::FileWriterTest < Minitest::Test
|
|
def test_write_creates_directories_writes_content_and_sets_permissions
|
|
Dir.mktmpdir do |dir|
|
|
path = File.join(dir, "nested", "file.txt")
|
|
Pressa::Utils::FileWriter.write(path:, content: "hello", permissions: 0o600)
|
|
|
|
assert_equal("hello", File.read(path))
|
|
assert_equal("600", format("%o", File.stat(path).mode & 0o777))
|
|
end
|
|
end
|
|
|
|
def test_write_data_writes_binary_content_and_sets_permissions
|
|
Dir.mktmpdir do |dir|
|
|
path = File.join(dir, "nested", "data.bin")
|
|
data = "\x00\xFFabc".b
|
|
Pressa::Utils::FileWriter.write_data(path:, data:, permissions: 0o640)
|
|
|
|
assert_equal(data, File.binread(path))
|
|
assert_equal("640", format("%o", File.stat(path).mode & 0o777))
|
|
end
|
|
end
|
|
end
|