Skip to content

Commit

Permalink
Add test for saving only ID3v2 and strip others (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinst committed Jun 10, 2012
1 parent 124d0c6 commit 0c6a9a7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/id3v2_write_test.rb
Expand Up @@ -8,6 +8,12 @@ class TestID3v2Write < Test::Unit::TestCase
OUTPUT_FILE = "test/data/output.mp3"
PICTURE_FILE = "test/data/globe_east_540.jpg"

def reloaded
TagLib::MPEG::File.open(OUTPUT_FILE, false) do |file|
yield file
end
end

context "TagLib::MPEG::File" do
setup do
FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
Expand All @@ -21,6 +27,26 @@ class TestID3v2Write < Test::Unit::TestCase
assert_nil @file.id3v2_tag
end

should "be able to save only ID3v2 tag" do
assert_not_nil @file.id3v2_tag
assert_not_nil @file.id3v1_tag
@file.save(TagLib::MPEG::File::ID3v2)
@file.close
@file = nil

reloaded do |file|
id3v1_tag = file.id3v1_tag
id3v2_tag = file.id3v2_tag

# TagLib always creates the tags
assert_not_nil id3v1_tag
assert_not_nil id3v2_tag

assert_equal true, file.id3v1_tag.empty?
assert_equal false, file.id3v2_tag.empty?
end
end

context "with a fresh tag" do
setup do
@file.strip
Expand Down

0 comments on commit 0c6a9a7

Please sign in to comment.