Sha256: 6fa1909dc18c45358e232aafd8e4a97542c5e7018b81dcf142079fbd82c3bc7f
Contents?: true
Size: 1.77 KB
Versions: 4
Compression:
Stored size: 1.77 KB
Contents
require 'test_helper' class TestToriBackendFileSystem < Test::Unit::TestCase setup do path = Pathname("test/tmp/tori/store") @filesystem = Tori::Backend::FileSystem.new(path) File.open(@filesystem.root.join("testfile"), 'w+'){ |f| f.write('text') } end teardown do FileUtils.rm_rf("test/tmp") end test "#initialize" do assert_instance_of Tori::Backend::FileSystem, @filesystem assert_raise(ArgumentError){ Tori::Backend::FileSystem.new } end test "#exist?" do assert { true == @filesystem.exist?(".") } assert { false == @filesystem.exist?("nothing_file") } end test "#read" do assert { "text" == @filesystem.read("testfile") } assert_raise(Errno::ENOENT){ @filesystem.read("nothing_file") } bin = (0..0xFF).to_a.pack("c*") File.open(@filesystem.root.join("binfile"), 'wb'){ |f| f.write bin } assert { bin == @filesystem.read("binfile") } end test "#path" do assert { Pathname.new("test/tmp/tori/store/testfile") == @filesystem.path("testfile") } end test "#write" do @filesystem.write("copyfile", @filesystem.path("testfile")) assert { "text" == @filesystem.read("copyfile") } File.open(@filesystem.path("testfile")) do |f| @filesystem.write("copyfile", f) end assert { "text" == @filesystem.read("copyfile") } @filesystem.write("copyfile", "string") assert { "string" == @filesystem.read("copyfile") } bin = (0..0xFF).to_a.pack("c*") @filesystem.write("binfile", bin) assert { bin == @filesystem.read("binfile") } @filesystem.write(Pathname.new("copyfile"), @filesystem.path("testfile")) assert { "text" == @filesystem.read("copyfile") } @filesystem.write(Pathname.new("copyfile"), "string") assert { "string" == @filesystem.read("copyfile") } end end
Version data entries
4 entries across 4 versions & 1 rubygems