Sha256: 5a2dec0cf6bfa3b1c216468768974696890a94464bfb14d6986d47b7b1e9ade7
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'test/unit' require 'date' require 'oj' require 'filentory/fileentry' class TestFileEntry < Test::Unit::TestCase def test_initialisation_with_a_path_and_a_name fe = FileEntry.new("/media/","a name") assert_equal("a name", fe.name) assert_equal("/media/", fe.path) end def test_checksum_can_be_set fe = FileEntry.new("/media/","a name") fe.checksum = "1234" assert_equal("1234", fe.checksum) end def test_last_modification_can_be_set fe = FileEntry.new("/media/","a name") last = DateTime.iso8601("2014-01-04T21:06:04+01:00") fe.last_modified = last assert_equal("2014-01-04T21:06:04+01:00", fe.last_modified.strftime("%FT%T%:z")) end def test_json_stores_datestring fe = FileEntry.new("/media/","a name") fe.last_modified = DateTime.iso8601("2014-01-04T21:06:04+01:00") json = Oj::dump fe, :indent => 2 assert_equal(json_compact.strip, json) end def test_to_s_is_readable fe = FileEntry.new("/media/","a name") fe.last_modified = DateTime.iso8601("2014-01-04T21:06:04+01:00") fe.size = 100 assert_equal("/media/a name (100) - 2014-01-04T21:06:04+01:00",fe.to_s) end private def json_compact <<-eos { "^o":"FileEntry", "path":"/media/", "name":"a name", "last_modified":"2014-01-04T21:06:04+01:00" } eos end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
filentory-cli-0.3.0 | test/tc_fileentry.rb |
filentory-cli-0.2.0 | test/tc_fileentry.rb |