samhuri.net/test/utils/file_writer_test.rb
Sami Samhuri 6eec569358
Rename spec suite to test and remove RSpec-era traces
Move Minitest files from spec/ to test/ and update bake tasks

to discover and run tests from test/**/*_test.rb.

Update README and AGENTS guidance to reference test/ and tests,

and drop the obsolete spec/examples.txt ignore entry.
2026-02-07 21:15:29 -08:00

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