X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=test%2Ftest_main.rb;h=a4a14504d463f1bf3f91786fd7b28445b1f4c97b;hb=e04f6c2b90c9501fc613a130ee90863cc84f4a98;hp=bbc5b0023a2987e31af883c4573dde96f4605dd5;hpb=bb2a2dcd813175bc4e1dc5ae087795ec18be8fa6;p=ruby-vorbistagger.git diff --git a/test/test_main.rb b/test/test_main.rb index bbc5b00..a4a1450 100644 --- a/test/test_main.rb +++ b/test/test_main.rb @@ -77,6 +77,16 @@ class MainTest < Test::Unit::TestCase end end + def test_write_keeps_file_mode + mode = File.stat(OGG_FILE).mode + + Ogg::Vorbis::Tagger.open(OGG_FILE) do |t| + t.write + end + + assert_equal(mode, File.stat(OGG_FILE).mode) + end + def test_append Ogg::Vorbis::Tagger.open(OGG_FILE) do |t| t.comments["genre"] = "Death Metal" @@ -252,4 +262,37 @@ EOF def test_close Ogg::Vorbis::Tagger.new(OGG_FILE).close end + + def test_close2 + t = Ogg::Vorbis::Tagger.new(OGG_FILE) + t.close + + assert_raise(Ogg::Vorbis::Tagger::ClosedStreamError) do + t.close + end + + assert_raise(Ogg::Vorbis::Tagger::ClosedStreamError) do + Ogg::Vorbis::Tagger.open(OGG_FILE) do |t| + t.close + end + end + end + + def test_open_non_existing_file + assert_raises(Ogg::Vorbis::Tagger::OpenError) do + Ogg::Vorbis::Tagger.new("foo.bar") + end + end + + def test_open_non_ogg_file + File.open("test/foo.bar", "w") do |f| + f << "foobarbazxyzzy" + end + + assert_raises(Ogg::Vorbis::Tagger::InvalidDataError) do + Ogg::Vorbis::Tagger.new("test/foo.bar") + end + ensure + FileUtils.rm_f("test/foo.bar") + end end