id3_tags 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,67 +0,0 @@
1
- require 'id3_tags'
2
- require_relative '../helpers/duplicate_file_helper'
3
-
4
- describe 'Id3Tags.write_tags_to' do
5
- context 'given a track with all the ID3 metadata and a Hash of empty ID3' do
6
- let(:original_track) {File.join File.dirname(__FILE__), '../assets/all_id3.mp3'}
7
- let(:new_metadata) { {} }
8
-
9
- it 'resets all the editable ID3 tags of the track to nil' do
10
- with_duplicate_file_of(original_track) do |duplicate|
11
- Id3Tags.write_tags_to(duplicate, new_metadata)
12
- id3_tags = Id3Tags.read_tags_from(duplicate)
13
- [:album, :artist, :comment, :genre, :title, :grouping, :lyrics,
14
- :album_artist, :composer, :bpm].each do |field|
15
- id3_tags[field].should be_nil
16
- end
17
- id3_tags[:year].should == 0
18
- id3_tags[:compilation].should be_false
19
- # NOTE: Taglib does NOT allow the track_number to be nil; the old
20
- # value is persisted in this case, so we cannot test for nil?
21
- #id3_tags[:track][:number].should be_nil
22
- id3_tags[:track][:count].should be_nil
23
- id3_tags[:disk][:number].should be_nil
24
- id3_tags[:disk][:count].should be_nil
25
- id3_tags[:cover_art][:mime_type].should be_nil
26
- id3_tags[:cover_art][:data].should be_nil
27
- end
28
- end
29
- end
30
-
31
- context 'given a track with no metadata and a Hash full of ID3' do
32
- let(:original_track) {File.join File.dirname(__FILE__), '../assets/no_id3.mp3'}
33
- let(:new_cover_art) {File.join File.dirname(__FILE__), '../assets/black_pixel.png'}
34
- let(:new_cover_art_data) {File.open(new_cover_art, 'rb') {|io| io.read}}
35
- let(:new_metadata) { {title: "A track", album: "An album", artist:
36
- "An artist", year: 2012, comment: "A comment", genre: "A genre", bpm: 68,
37
- composer: "A composer", lyrics: "A lyrics line 1\rand line 2",
38
- album_artist: "An album artist", grouping: "A group", compilation: true,
39
- track: {number: 1, count: 24}, disk: {number: 1, count: 2}, cover_art:
40
- {mime_type: "image/png", data: new_cover_art_data}}
41
- }
42
-
43
- it 'sets all the editable ID3 tags of a track' do
44
- with_duplicate_file_of(original_track) do |duplicate|
45
- Id3Tags.write_tags_to(duplicate, new_metadata)
46
- id3_tags = Id3Tags.read_tags_from(duplicate)
47
- id3_tags[:album].should == 'An album'
48
- id3_tags[:artist].should == 'An artist'
49
- id3_tags[:comment].should == 'A comment'
50
- id3_tags[:genre].should == 'A genre'
51
- id3_tags[:title].should == 'A track'
52
- id3_tags[:grouping].should == 'A group'
53
- id3_tags[:lyrics].should == "A lyrics line 1\rand line 2"
54
- id3_tags[:album_artist].should == 'An album artist'
55
- id3_tags[:composer].should == 'A composer'
56
- id3_tags[:bpm].should == 68
57
- id3_tags[:compilation].should be_true
58
- id3_tags[:track][:number].should == 1
59
- id3_tags[:track][:count].should == 24
60
- id3_tags[:disk][:number].should == 1
61
- id3_tags[:disk][:count].should == 2
62
- id3_tags[:cover_art][:mime_type].should == 'image/png'
63
- id3_tags[:cover_art][:data].should == new_cover_art_data
64
- end
65
- end
66
- end
67
- end