id3tag 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -46
  3. data/.travis.yml +6 -5
  4. data/id3tag.gemspec +8 -8
  5. data/lib/id3tag/audio_file.rb +24 -6
  6. data/lib/id3tag/id3_v2_tag_header.rb +4 -4
  7. data/lib/id3tag/number_util.rb +1 -0
  8. data/lib/id3tag/tag.rb +2 -2
  9. data/lib/id3tag/version.rb +1 -1
  10. data/spec/features/can_read_non_audio_files_spec.rb +8 -7
  11. data/spec/features/can_read_tag_v1_spec.rb +6 -6
  12. data/spec/lib/id3tag/audio_file_spec.rb +85 -15
  13. data/spec/lib/id3tag/frames/util/genre_name_by_id_finder_spec.rb +2 -2
  14. data/spec/lib/id3tag/frames/v1/comments_frame_spec.rb +7 -7
  15. data/spec/lib/id3tag/frames/v1/genre_frame_spec.rb +3 -3
  16. data/spec/lib/id3tag/frames/v1/text_frame_spec.rb +2 -2
  17. data/spec/lib/id3tag/frames/v1/track_nr_frame_spec.rb +3 -3
  18. data/spec/lib/id3tag/frames/v2/basic_frame_spec.rb +56 -16
  19. data/spec/lib/id3tag/frames/v2/comments_frame_spec.rb +5 -5
  20. data/spec/lib/id3tag/frames/v2/frame_fabricator_spec.rb +8 -8
  21. data/spec/lib/id3tag/frames/v2/frame_flags_spec.rb +539 -108
  22. data/spec/lib/id3tag/frames/v2/genre_frame/genre_parser_24_spec.rb +3 -3
  23. data/spec/lib/id3tag/frames/v2/genre_frame/genre_parser_pre_24_spec.rb +8 -8
  24. data/spec/lib/id3tag/frames/v2/genre_frame_spec.rb +9 -9
  25. data/spec/lib/id3tag/frames/v2/picture_frame_spec.rb +37 -17
  26. data/spec/lib/id3tag/frames/v2/text_frame_spec.rb +7 -7
  27. data/spec/lib/id3tag/frames/v2/unique_file_id_frame_spec.rb +4 -4
  28. data/spec/lib/id3tag/frames/v2/user_text_frame_spec.rb +19 -4
  29. data/spec/lib/id3tag/id3_v1_frame_parser_spec.rb +10 -10
  30. data/spec/lib/id3tag/id3_v2_frame_parser_spec.rb +6 -6
  31. data/spec/lib/id3tag/id3_v2_tag_header_spec.rb +105 -21
  32. data/spec/lib/id3tag/id3tag_spec.rb +1 -1
  33. data/spec/lib/id3tag/io_util_spec.rb +4 -4
  34. data/spec/lib/id3tag/number_util_spec.rb +10 -2
  35. data/spec/lib/id3tag/string_util_spec.rb +10 -10
  36. data/spec/lib/id3tag/synchsafe_integer_spec.rb +6 -6
  37. data/spec/lib/id3tag/tag_spec.rb +192 -91
  38. metadata +28 -29
  39. data/Gemfile.lock +0 -77
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
  describe ID3Tag::Frames::V1::GenreFrame do
3
3
  describe '#id' do
4
4
  subject { described_class.new('genre', nil).id }
5
- it { should == 'genre' }
5
+ it { is_expected.to eq('genre') }
6
6
  end
7
7
 
8
8
  describe '#content' do
9
9
  context 'when genre is blues' do
10
10
  subject { described_class.new('genre', [0].pack('c')).content }
11
- it { should == 'Blues' }
11
+ it { is_expected.to eq('Blues') }
12
12
  end
13
13
 
14
14
  context 'when genre is metal' do
15
15
  subject { described_class.new('genre', [9].pack('c')).content }
16
- it { should == 'Metal' }
16
+ it { is_expected.to eq('Metal') }
17
17
  end
18
18
  end
19
19
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
  describe ID3Tag::Frames::V1::TextFrame do
3
3
  describe '#id' do
4
4
  subject { described_class.new('album', nil).id }
5
- it { should == 'album' }
5
+ it { is_expected.to eq('album') }
6
6
  end
7
7
 
8
8
  describe '#content' do
9
9
  context 'when containing track artist' do
10
10
  subject { described_class.new('artist', 'some fancy artist').content }
11
- it { should == 'some fancy artist' }
11
+ it { is_expected.to eq('some fancy artist') }
12
12
  end
13
13
  end
14
14
  end
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
  describe ID3Tag::Frames::V1::TrackNrFrame do
3
3
  describe '#id' do
4
4
  subject { described_class.new('track_nr', nil).id }
5
- it { should == 'track_nr' }
5
+ it { is_expected.to eq('track_nr') }
6
6
  end
7
7
 
8
8
  describe '#content' do
9
9
  context 'when nr is 3' do
10
10
  subject { described_class.new('track_nr', [3].pack('c')).content }
11
- it { should == '3' }
11
+ it { is_expected.to eq('3') }
12
12
  end
13
13
 
14
14
  context 'when nr is 11' do
15
15
  subject { described_class.new('track_nr', [11].pack('c')).content }
16
- it { should == '11' }
16
+ it { is_expected.to eq('11') }
17
17
  end
18
18
  end
19
19
  end
@@ -9,17 +9,21 @@ describe ID3Tag::Frames::V2::BasicFrame do
9
9
 
10
10
  describe '#id' do
11
11
  subject { frame.id }
12
- it { should == :foo }
12
+ it { is_expected.to eq(:foo) }
13
13
  end
14
14
 
15
15
  describe '#content' do
16
16
  subject { frame.content }
17
- it { should == 'bar' }
17
+ it { is_expected.to eq('bar') }
18
18
  context "when frame contains unsynchronised content" do
19
19
  subject { frame }
20
20
  let(:flags) { [0b00000000, 0b00000010].pack("C2") }
21
21
  let(:raw_content) { "\xFF\x00\xEE\xEE" }
22
- its(:content) { should eq("\xFF\xEE\xEE") }
22
+
23
+ describe '#content' do
24
+ subject { super().content }
25
+ it { is_expected.to eq("\xFF\xEE\xEE") }
26
+ end
23
27
  end
24
28
  end
25
29
 
@@ -28,13 +32,25 @@ describe ID3Tag::Frames::V2::BasicFrame do
28
32
  context "when all frags nulled" do
29
33
  let(:raw_content) { 'foo' }
30
34
  let(:flags) { nil }
31
- its(:final_size) { should eq 3 }
35
+
36
+ describe '#final_size' do
37
+ subject { super().final_size }
38
+ it { is_expected.to eq 3 }
39
+ end
32
40
  end
33
41
  context "when frame is compressed and data length is set" do
34
42
  let(:flags) { [0b00000000, 0b00001001].pack("C2") }
35
43
  let(:raw_content) { [55].pack("N") + 'foo' }
36
- its(:final_size) { should eq 55 }
37
- its(:content) { should eq "foo" }
44
+
45
+ describe '#final_size' do
46
+ subject { super().final_size }
47
+ it { is_expected.to eq 55 }
48
+ end
49
+
50
+ describe '#content' do
51
+ subject { super().content }
52
+ it { is_expected.to eq "foo" }
53
+ end
38
54
  end
39
55
  end
40
56
 
@@ -43,13 +59,25 @@ describe ID3Tag::Frames::V2::BasicFrame do
43
59
  context "when all frags nulled" do
44
60
  let(:raw_content) { 'foo' }
45
61
  let(:flags) { nil }
46
- its(:group_id) { should eq nil }
62
+
63
+ describe '#group_id' do
64
+ subject { super().group_id }
65
+ it { is_expected.to eq nil }
66
+ end
47
67
  end
48
68
  context "when frame is compressed and data length is set" do
49
69
  let(:flags) { [0b00000000, 0b01000000].pack("C2") }
50
70
  let(:raw_content) { [33].pack("C") + 'foo' }
51
- its(:content) { should eq "foo" }
52
- its(:group_id) { should eq 33 }
71
+
72
+ describe '#content' do
73
+ subject { super().content }
74
+ it { is_expected.to eq "foo" }
75
+ end
76
+
77
+ describe '#group_id' do
78
+ subject { super().group_id }
79
+ it { is_expected.to eq 33 }
80
+ end
53
81
  end
54
82
  end
55
83
 
@@ -58,13 +86,25 @@ describe ID3Tag::Frames::V2::BasicFrame do
58
86
  context "when all frags nulled" do
59
87
  let(:raw_content) { 'foo' }
60
88
  let(:flags) { nil }
61
- its(:encryption_id) { should eq nil }
89
+
90
+ describe '#encryption_id' do
91
+ subject { super().encryption_id }
92
+ it { is_expected.to eq nil }
93
+ end
62
94
  end
63
95
  context "when frame is compressed and data length is set" do
64
96
  let(:flags) { [0b00000000, 0b00000100].pack("C2") }
65
97
  let(:raw_content) { [1].pack("C") + 'foo' }
66
- its(:content) { should eq "foo" }
67
- its(:encryption_id) { should eq 1 }
98
+
99
+ describe '#content' do
100
+ subject { super().content }
101
+ it { is_expected.to eq "foo" }
102
+ end
103
+
104
+ describe '#encryption_id' do
105
+ subject { super().encryption_id }
106
+ it { is_expected.to eq 1 }
107
+ end
68
108
  end
69
109
  end
70
110
 
@@ -72,21 +112,21 @@ describe ID3Tag::Frames::V2::BasicFrame do
72
112
  subject { frame }
73
113
  describe "#read_only?" do
74
114
  it "should delegate to FrameFlags class" do
75
- ID3Tag::Frames::V2::FrameFlags.any_instance.should_receive(:read_only?)
115
+ expect_any_instance_of(ID3Tag::Frames::V2::FrameFlags).to receive(:read_only?)
76
116
  subject.read_only?
77
117
  end
78
118
  end
79
119
 
80
120
  describe "#preserve_on_tag_alteration?" do
81
121
  it "should delegate to FrameFlags class" do
82
- ID3Tag::Frames::V2::FrameFlags.any_instance.should_receive(:preserve_on_tag_alteration?)
122
+ expect_any_instance_of(ID3Tag::Frames::V2::FrameFlags).to receive(:preserve_on_tag_alteration?)
83
123
  subject.preserve_on_tag_alteration?
84
124
  end
85
125
  end
86
126
 
87
127
  describe "#preserve_on_file_alteration?" do
88
128
  it "should delegate to FrameFlags class" do
89
- ID3Tag::Frames::V2::FrameFlags.any_instance.should_receive(:preserve_on_file_alteration?)
129
+ expect_any_instance_of(ID3Tag::Frames::V2::FrameFlags).to receive(:preserve_on_file_alteration?)
90
130
  subject.preserve_on_file_alteration?
91
131
  end
92
132
  end
@@ -94,7 +134,7 @@ describe ID3Tag::Frames::V2::BasicFrame do
94
134
 
95
135
  describe '#inspect' do
96
136
  it 'should be pretty inspectable' do
97
- frame.inspect.should eq('<ID3Tag::Frames::V2::BasicFrame foo>')
137
+ expect(frame.inspect).to eq('<ID3Tag::Frames::V2::BasicFrame foo>')
98
138
  end
99
139
  end
100
140
  end
@@ -19,27 +19,27 @@ describe ID3Tag::Frames::V2::CommentsFrame do
19
19
 
20
20
  describe '#id' do
21
21
  subject { frame.id }
22
- it { should == :COMM }
22
+ it { is_expected.to eq(:COMM) }
23
23
  end
24
24
 
25
25
  describe '#content' do
26
26
  subject { frame.content }
27
- it { should == 'Glāzšķūņrūķīši' }
27
+ it { is_expected.to eq('Glāzšķūņrūķīši') }
28
28
  end
29
29
 
30
30
  describe '#language' do
31
31
  subject { frame.language }
32
- it { should == 'lav' }
32
+ it { is_expected.to eq('lav') }
33
33
  end
34
34
 
35
35
  describe '#description' do
36
36
  subject { frame.description }
37
- it { should == 'bob once said' }
37
+ it { is_expected.to eq('bob once said') }
38
38
  end
39
39
 
40
40
  describe '#inspect' do
41
41
  it 'should be pretty inspectable' do
42
- frame.inspect.should eq('<ID3Tag::Frames::V2::CommentsFrame COMM: Glāzšķūņrūķīši>')
42
+ expect(frame.inspect).to eq('<ID3Tag::Frames::V2::CommentsFrame COMM: Glāzšķūņrūķīši>')
43
43
  end
44
44
  end
45
45
  end
@@ -11,7 +11,7 @@ describe ID3Tag::Frames::V2::FrameFabricator do
11
11
  context "when frame is a genre frame TCON" do
12
12
  let(:id) { "TCON" }
13
13
  it "fabricates genre frame" do
14
- ID3Tag::Frames::V2::GenreFrame.should_receive(:new).with(id, content, flags, major_version_number)
14
+ expect(ID3Tag::Frames::V2::GenreFrame).to receive(:new).with(id, content, flags, major_version_number)
15
15
  subject
16
16
  end
17
17
  end
@@ -19,49 +19,49 @@ describe ID3Tag::Frames::V2::FrameFabricator do
19
19
  context "when frame is a genre frame TCO" do
20
20
  let(:id) { "TCO" }
21
21
  it "fabricates genre frame" do
22
- ID3Tag::Frames::V2::GenreFrame.should_receive(:new).with(id, content, flags, major_version_number)
22
+ expect(ID3Tag::Frames::V2::GenreFrame).to receive(:new).with(id, content, flags, major_version_number)
23
23
  subject
24
24
  end
25
25
  end
26
26
  context "when frame is a text frame TIT2" do
27
27
  let(:id) { "TIT2" }
28
28
  it "fabricates text frame" do
29
- ID3Tag::Frames::V2::TextFrame.should_receive(:new).with(id, content, flags, major_version_number)
29
+ expect(ID3Tag::Frames::V2::TextFrame).to receive(:new).with(id, content, flags, major_version_number)
30
30
  subject
31
31
  end
32
32
  end
33
33
  context "when frame is a user text frame" do
34
34
  let(:id) { "TXX" }
35
35
  it "fabricates user text frame" do
36
- ID3Tag::Frames::V2::UserTextFrame.should_receive(:new).with(id, content, flags, major_version_number)
36
+ expect(ID3Tag::Frames::V2::UserTextFrame).to receive(:new).with(id, content, flags, major_version_number)
37
37
  subject
38
38
  end
39
39
  end
40
40
  context "when frame is a comment frame COM" do
41
41
  let(:id) { "COMM" }
42
42
  it "fabricates comment frame" do
43
- ID3Tag::Frames::V2::CommentsFrame.should_receive(:new).with(id, content, flags, major_version_number)
43
+ expect(ID3Tag::Frames::V2::CommentsFrame).to receive(:new).with(id, content, flags, major_version_number)
44
44
  subject
45
45
  end
46
46
  end
47
47
  context "when frame is a unique id" do
48
48
  let(:id) { "UFID" }
49
49
  it "fabricates unique id frame" do
50
- ID3Tag::Frames::V2::UniqueFileIdFrame.should_receive(:new).with(id, content, flags, major_version_number)
50
+ expect(ID3Tag::Frames::V2::UniqueFileIdFrame).to receive(:new).with(id, content, flags, major_version_number)
51
51
  subject
52
52
  end
53
53
  end
54
54
  context "when frame is a unique id" do
55
55
  let(:id) { "IPLS" }
56
56
  it "fabricates involved people list frame" do
57
- ID3Tag::Frames::V2::InvolvedPeopleListFrame.should_receive(:new).with(id, content, flags, major_version_number)
57
+ expect(ID3Tag::Frames::V2::InvolvedPeopleListFrame).to receive(:new).with(id, content, flags, major_version_number)
58
58
  subject
59
59
  end
60
60
  end
61
61
  context "when frame is a unknown" do
62
62
  let(:id) { "unknown" }
63
63
  it "fabricates basic frame" do
64
- ID3Tag::Frames::V2::BasicFrame.should_receive(:new).with(id, content, flags, major_version_number)
64
+ expect(ID3Tag::Frames::V2::BasicFrame).to receive(:new).with(id, content, flags, major_version_number)
65
65
  subject
66
66
  end
67
67
  end
@@ -7,84 +7,323 @@ describe ID3Tag::Frames::V2::FrameFlags do
7
7
  let(:flag_bytes) { nil }
8
8
  let(:version) { 2 }
9
9
 
10
- its(:preserve_on_tag_alteration?) { should be_true }
11
- its(:preserve_on_file_alteration?) { should be_true }
12
- its(:read_only?) { should be_false }
13
- its(:compressed?) { should be_false }
14
- its(:encrypted?) { should be_false }
15
- its(:grouped?) { should be_false }
16
- its(:unsynchronised?) { should be_false }
17
- its(:data_length_indicator?) { should be_false }
18
- its(:additional_info_byte_count) { should eq 0 }
19
- its(:position_and_count_of_data_length_bytes) { should eq nil }
20
- its(:position_and_count_of_group_id_bytes) { should eq nil }
21
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
10
+ describe '#preserve_on_tag_alteration?' do
11
+ subject { super().preserve_on_tag_alteration? }
12
+ it { is_expected.to eq(true) }
13
+ end
14
+
15
+ describe '#preserve_on_file_alteration?' do
16
+ subject { super().preserve_on_file_alteration? }
17
+ it { is_expected.to eq(true) }
18
+ end
19
+
20
+ describe '#read_only?' do
21
+ subject { super().read_only? }
22
+ it { is_expected.to eq(false) }
23
+ end
24
+
25
+ describe '#compressed?' do
26
+ subject { super().compressed? }
27
+ it { is_expected.to eq(false) }
28
+ end
29
+
30
+ describe '#encrypted?' do
31
+ subject { super().encrypted? }
32
+ it { is_expected.to eq(false) }
33
+ end
34
+
35
+ describe '#grouped?' do
36
+ subject { super().grouped? }
37
+ it { is_expected.to eq(false) }
38
+ end
39
+
40
+ describe '#unsynchronised?' do
41
+ subject { super().unsynchronised? }
42
+ it { is_expected.to eq(false) }
43
+ end
44
+
45
+ describe '#data_length_indicator?' do
46
+ subject { super().data_length_indicator? }
47
+ it { is_expected.to eq(false) }
48
+ end
49
+
50
+ describe '#additional_info_byte_count' do
51
+ subject { super().additional_info_byte_count }
52
+ it { is_expected.to eq 0 }
53
+ end
54
+
55
+ describe '#position_and_count_of_data_length_bytes' do
56
+ subject { super().position_and_count_of_data_length_bytes }
57
+ it { is_expected.to eq nil }
58
+ end
59
+
60
+ describe '#position_and_count_of_group_id_bytes' do
61
+ subject { super().position_and_count_of_group_id_bytes }
62
+ it { is_expected.to eq nil }
63
+ end
64
+
65
+ describe '#position_and_count_of_encryption_id_bytes' do
66
+ subject { super().position_and_count_of_encryption_id_bytes }
67
+ it { is_expected.to eq nil }
68
+ end
22
69
  end
23
70
 
24
71
  context "when major version is 3" do
25
72
  let(:version) { 3 }
26
73
  context "when all flags are nulled" do
27
74
  let(:flag_bytes) { [0b00000000, 0b00000000].pack("C2") }
28
- its(:preserve_on_tag_alteration?) { should be_true }
29
- its(:preserve_on_file_alteration?) { should be_true }
30
- its(:read_only?) { should be_false }
31
- its(:compressed?) { should be_false }
32
- its(:encrypted?) { should be_false }
33
- its(:grouped?) { should be_false }
34
- its(:unsynchronised?) { should be_false }
35
- its(:data_length_indicator?) { should be_false }
36
- its(:additional_info_byte_count) { should eq 0 }
37
- its(:position_and_count_of_data_length_bytes) { should eq nil }
38
- its(:position_and_count_of_group_id_bytes) { should eq nil }
39
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
75
+
76
+ describe '#preserve_on_tag_alteration?' do
77
+ subject { super().preserve_on_tag_alteration? }
78
+ it { is_expected.to eq(true) }
79
+ end
80
+
81
+ describe '#preserve_on_file_alteration?' do
82
+ subject { super().preserve_on_file_alteration? }
83
+ it { is_expected.to eq(true) }
84
+ end
85
+
86
+ describe '#read_only?' do
87
+ subject { super().read_only? }
88
+ it { is_expected.to eq(false) }
89
+ end
90
+
91
+ describe '#compressed?' do
92
+ subject { super().compressed? }
93
+ it { is_expected.to eq(false) }
94
+ end
95
+
96
+ describe '#encrypted?' do
97
+ subject { super().encrypted? }
98
+ it { is_expected.to eq(false) }
99
+ end
100
+
101
+ describe '#grouped?' do
102
+ subject { super().grouped? }
103
+ it { is_expected.to eq(false) }
104
+ end
105
+
106
+ describe '#unsynchronised?' do
107
+ subject { super().unsynchronised? }
108
+ it { is_expected.to eq(false) }
109
+ end
110
+
111
+ describe '#data_length_indicator?' do
112
+ subject { super().data_length_indicator? }
113
+ it { is_expected.to eq(false) }
114
+ end
115
+
116
+ describe '#additional_info_byte_count' do
117
+ subject { super().additional_info_byte_count }
118
+ it { is_expected.to eq 0 }
119
+ end
120
+
121
+ describe '#position_and_count_of_data_length_bytes' do
122
+ subject { super().position_and_count_of_data_length_bytes }
123
+ it { is_expected.to eq nil }
124
+ end
125
+
126
+ describe '#position_and_count_of_group_id_bytes' do
127
+ subject { super().position_and_count_of_group_id_bytes }
128
+ it { is_expected.to eq nil }
129
+ end
130
+
131
+ describe '#position_and_count_of_encryption_id_bytes' do
132
+ subject { super().position_and_count_of_encryption_id_bytes }
133
+ it { is_expected.to eq nil }
134
+ end
40
135
  end
41
136
 
42
137
  context "when compression is on" do
43
138
  let(:flag_bytes) { [0b00000000, 0b10000000].pack("C2") }
44
- its(:preserve_on_tag_alteration?) { should be_true }
45
- its(:preserve_on_file_alteration?) { should be_true }
46
- its(:read_only?) { should be_false }
47
- its(:compressed?) { should be_true }
48
- its(:encrypted?) { should be_false }
49
- its(:grouped?) { should be_false }
50
- its(:unsynchronised?) { should be_false }
51
- its(:data_length_indicator?) { should be_false }
52
- its(:additional_info_byte_count) { should eq 4 }
53
- its(:position_and_count_of_data_length_bytes) { should eq [0, 4] }
54
- its(:position_and_count_of_group_id_bytes) { should eq nil }
55
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
139
+
140
+ describe '#preserve_on_tag_alteration?' do
141
+ subject { super().preserve_on_tag_alteration? }
142
+ it { is_expected.to eq(true) }
143
+ end
144
+
145
+ describe '#preserve_on_file_alteration?' do
146
+ subject { super().preserve_on_file_alteration? }
147
+ it { is_expected.to eq(true) }
148
+ end
149
+
150
+ describe '#read_only?' do
151
+ subject { super().read_only? }
152
+ it { is_expected.to eq(false) }
153
+ end
154
+
155
+ describe '#compressed?' do
156
+ subject { super().compressed? }
157
+ it { is_expected.to eq(true) }
158
+ end
159
+
160
+ describe '#encrypted?' do
161
+ subject { super().encrypted? }
162
+ it { is_expected.to eq(false) }
163
+ end
164
+
165
+ describe '#grouped?' do
166
+ subject { super().grouped? }
167
+ it { is_expected.to eq(false) }
168
+ end
169
+
170
+ describe '#unsynchronised?' do
171
+ subject { super().unsynchronised? }
172
+ it { is_expected.to eq(false) }
173
+ end
174
+
175
+ describe '#data_length_indicator?' do
176
+ subject { super().data_length_indicator? }
177
+ it { is_expected.to eq(false) }
178
+ end
179
+
180
+ describe '#additional_info_byte_count' do
181
+ subject { super().additional_info_byte_count }
182
+ it { is_expected.to eq 4 }
183
+ end
184
+
185
+ describe '#position_and_count_of_data_length_bytes' do
186
+ subject { super().position_and_count_of_data_length_bytes }
187
+ it { is_expected.to eq [0, 4] }
188
+ end
189
+
190
+ describe '#position_and_count_of_group_id_bytes' do
191
+ subject { super().position_and_count_of_group_id_bytes }
192
+ it { is_expected.to eq nil }
193
+ end
194
+
195
+ describe '#position_and_count_of_encryption_id_bytes' do
196
+ subject { super().position_and_count_of_encryption_id_bytes }
197
+ it { is_expected.to eq nil }
198
+ end
56
199
  end
57
200
 
58
201
  context "when compression and group id is on" do
59
202
  let(:flag_bytes) { [0b00000000, 0b10100000].pack("C2") }
60
- its(:preserve_on_tag_alteration?) { should be_true }
61
- its(:preserve_on_file_alteration?) { should be_true }
62
- its(:read_only?) { should be_false }
63
- its(:compressed?) { should be_true }
64
- its(:encrypted?) { should be_false }
65
- its(:grouped?) { should be_true }
66
- its(:unsynchronised?) { should be_false }
67
- its(:data_length_indicator?) { should be_false }
68
- its(:additional_info_byte_count) { should eq 5 }
69
- its(:position_and_count_of_data_length_bytes) { should eq [0, 4] }
70
- its(:position_and_count_of_group_id_bytes) { should eq [4, 1] }
71
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
203
+
204
+ describe '#preserve_on_tag_alteration?' do
205
+ subject { super().preserve_on_tag_alteration? }
206
+ it { is_expected.to eq(true) }
207
+ end
208
+
209
+ describe '#preserve_on_file_alteration?' do
210
+ subject { super().preserve_on_file_alteration? }
211
+ it { is_expected.to eq(true) }
212
+ end
213
+
214
+ describe '#read_only?' do
215
+ subject { super().read_only? }
216
+ it { is_expected.to eq(false) }
217
+ end
218
+
219
+ describe '#compressed?' do
220
+ subject { super().compressed? }
221
+ it { is_expected.to eq(true) }
222
+ end
223
+
224
+ describe '#encrypted?' do
225
+ subject { super().encrypted? }
226
+ it { is_expected.to eq(false) }
227
+ end
228
+
229
+ describe '#grouped?' do
230
+ subject { super().grouped? }
231
+ it { is_expected.to eq(true) }
232
+ end
233
+
234
+ describe '#unsynchronised?' do
235
+ subject { super().unsynchronised? }
236
+ it { is_expected.to eq(false) }
237
+ end
238
+
239
+ describe '#data_length_indicator?' do
240
+ subject { super().data_length_indicator? }
241
+ it { is_expected.to eq(false) }
242
+ end
243
+
244
+ describe '#additional_info_byte_count' do
245
+ subject { super().additional_info_byte_count }
246
+ it { is_expected.to eq 5 }
247
+ end
248
+
249
+ describe '#position_and_count_of_data_length_bytes' do
250
+ subject { super().position_and_count_of_data_length_bytes }
251
+ it { is_expected.to eq [0, 4] }
252
+ end
253
+
254
+ describe '#position_and_count_of_group_id_bytes' do
255
+ subject { super().position_and_count_of_group_id_bytes }
256
+ it { is_expected.to eq [4, 1] }
257
+ end
258
+
259
+ describe '#position_and_count_of_encryption_id_bytes' do
260
+ subject { super().position_and_count_of_encryption_id_bytes }
261
+ it { is_expected.to eq nil }
262
+ end
72
263
  end
73
264
 
74
265
  context "when all flags are 1" do
75
266
  let(:flag_bytes) { [0b11100000, 0b11100000].pack("C2") }
76
- its(:preserve_on_tag_alteration?) { should be_false }
77
- its(:preserve_on_file_alteration?) { should be_false }
78
- its(:read_only?) { should be_true }
79
- its(:compressed?) { should be_true }
80
- its(:encrypted?) { should be_true }
81
- its(:grouped?) { should be_true }
82
- its(:unsynchronised?) { should be_false }
83
- its(:data_length_indicator?) { should be_false }
84
- its(:additional_info_byte_count) { should eq 6 }
85
- its(:position_and_count_of_data_length_bytes) { should eq [0, 4] }
86
- its(:position_and_count_of_group_id_bytes) { should eq [5, 1] }
87
- its(:position_and_count_of_encryption_id_bytes) { should eq [4, 1] }
267
+
268
+ describe '#preserve_on_tag_alteration?' do
269
+ subject { super().preserve_on_tag_alteration? }
270
+ it { is_expected.to eq(false) }
271
+ end
272
+
273
+ describe '#preserve_on_file_alteration?' do
274
+ subject { super().preserve_on_file_alteration? }
275
+ it { is_expected.to eq(false) }
276
+ end
277
+
278
+ describe '#read_only?' do
279
+ subject { super().read_only? }
280
+ it { is_expected.to eq(true) }
281
+ end
282
+
283
+ describe '#compressed?' do
284
+ subject { super().compressed? }
285
+ it { is_expected.to eq(true) }
286
+ end
287
+
288
+ describe '#encrypted?' do
289
+ subject { super().encrypted? }
290
+ it { is_expected.to eq(true) }
291
+ end
292
+
293
+ describe '#grouped?' do
294
+ subject { super().grouped? }
295
+ it { is_expected.to eq(true) }
296
+ end
297
+
298
+ describe '#unsynchronised?' do
299
+ subject { super().unsynchronised? }
300
+ it { is_expected.to eq(false) }
301
+ end
302
+
303
+ describe '#data_length_indicator?' do
304
+ subject { super().data_length_indicator? }
305
+ it { is_expected.to eq(false) }
306
+ end
307
+
308
+ describe '#additional_info_byte_count' do
309
+ subject { super().additional_info_byte_count }
310
+ it { is_expected.to eq 6 }
311
+ end
312
+
313
+ describe '#position_and_count_of_data_length_bytes' do
314
+ subject { super().position_and_count_of_data_length_bytes }
315
+ it { is_expected.to eq [0, 4] }
316
+ end
317
+
318
+ describe '#position_and_count_of_group_id_bytes' do
319
+ subject { super().position_and_count_of_group_id_bytes }
320
+ it { is_expected.to eq [5, 1] }
321
+ end
322
+
323
+ describe '#position_and_count_of_encryption_id_bytes' do
324
+ subject { super().position_and_count_of_encryption_id_bytes }
325
+ it { is_expected.to eq [4, 1] }
326
+ end
88
327
  end
89
328
  end
90
329
 
@@ -92,66 +331,258 @@ describe ID3Tag::Frames::V2::FrameFlags do
92
331
  let(:version) { 4 }
93
332
  context "when all flags are nulled" do
94
333
  let(:flag_bytes) { [0b00000000, 0b00000000].pack("C2") }
95
- its(:preserve_on_tag_alteration?) { should be_true }
96
- its(:preserve_on_file_alteration?) { should be_true }
97
- its(:read_only?) { should be_false }
98
- its(:compressed?) { should be_false }
99
- its(:encrypted?) { should be_false }
100
- its(:grouped?) { should be_false }
101
- its(:unsynchronised?) { should be_false }
102
- its(:data_length_indicator?) { should be_false }
103
- its(:additional_info_byte_count) { should eq 0 }
104
- its(:position_and_count_of_data_length_bytes) { should eq nil }
105
- its(:position_and_count_of_group_id_bytes) { should eq nil }
106
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
334
+
335
+ describe '#preserve_on_tag_alteration?' do
336
+ subject { super().preserve_on_tag_alteration? }
337
+ it { is_expected.to eq(true) }
338
+ end
339
+
340
+ describe '#preserve_on_file_alteration?' do
341
+ subject { super().preserve_on_file_alteration? }
342
+ it { is_expected.to eq(true) }
343
+ end
344
+
345
+ describe '#read_only?' do
346
+ subject { super().read_only? }
347
+ it { is_expected.to eq(false) }
348
+ end
349
+
350
+ describe '#compressed?' do
351
+ subject { super().compressed? }
352
+ it { is_expected.to eq(false) }
353
+ end
354
+
355
+ describe '#encrypted?' do
356
+ subject { super().encrypted? }
357
+ it { is_expected.to eq(false) }
358
+ end
359
+
360
+ describe '#grouped?' do
361
+ subject { super().grouped? }
362
+ it { is_expected.to eq(false) }
363
+ end
364
+
365
+ describe '#unsynchronised?' do
366
+ subject { super().unsynchronised? }
367
+ it { is_expected.to eq(false) }
368
+ end
369
+
370
+ describe '#data_length_indicator?' do
371
+ subject { super().data_length_indicator? }
372
+ it { is_expected.to eq(false) }
373
+ end
374
+
375
+ describe '#additional_info_byte_count' do
376
+ subject { super().additional_info_byte_count }
377
+ it { is_expected.to eq 0 }
378
+ end
379
+
380
+ describe '#position_and_count_of_data_length_bytes' do
381
+ subject { super().position_and_count_of_data_length_bytes }
382
+ it { is_expected.to eq nil }
383
+ end
384
+
385
+ describe '#position_and_count_of_group_id_bytes' do
386
+ subject { super().position_and_count_of_group_id_bytes }
387
+ it { is_expected.to eq nil }
388
+ end
389
+
390
+ describe '#position_and_count_of_encryption_id_bytes' do
391
+ subject { super().position_and_count_of_encryption_id_bytes }
392
+ it { is_expected.to eq nil }
393
+ end
107
394
  end
108
395
 
109
396
  context "when compression is on" do
110
397
  let(:flag_bytes) { [0b00000000, 0b00001001].pack("C2") }
111
- its(:preserve_on_tag_alteration?) { should be_true }
112
- its(:preserve_on_file_alteration?) { should be_true }
113
- its(:read_only?) { should be_false }
114
- its(:compressed?) { should be_true }
115
- its(:encrypted?) { should be_false }
116
- its(:grouped?) { should be_false }
117
- its(:unsynchronised?) { should be_false }
118
- its(:data_length_indicator?) { should be_true }
119
- its(:additional_info_byte_count) { should eq 4 }
120
- its(:position_and_count_of_data_length_bytes) { should eq [0, 4] }
121
- its(:position_and_count_of_group_id_bytes) { should eq nil }
122
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
398
+
399
+ describe '#preserve_on_tag_alteration?' do
400
+ subject { super().preserve_on_tag_alteration? }
401
+ it { is_expected.to eq(true) }
402
+ end
403
+
404
+ describe '#preserve_on_file_alteration?' do
405
+ subject { super().preserve_on_file_alteration? }
406
+ it { is_expected.to eq(true) }
407
+ end
408
+
409
+ describe '#read_only?' do
410
+ subject { super().read_only? }
411
+ it { is_expected.to eq(false) }
412
+ end
413
+
414
+ describe '#compressed?' do
415
+ subject { super().compressed? }
416
+ it { is_expected.to eq(true) }
417
+ end
418
+
419
+ describe '#encrypted?' do
420
+ subject { super().encrypted? }
421
+ it { is_expected.to eq(false) }
422
+ end
423
+
424
+ describe '#grouped?' do
425
+ subject { super().grouped? }
426
+ it { is_expected.to eq(false) }
427
+ end
428
+
429
+ describe '#unsynchronised?' do
430
+ subject { super().unsynchronised? }
431
+ it { is_expected.to eq(false) }
432
+ end
433
+
434
+ describe '#data_length_indicator?' do
435
+ subject { super().data_length_indicator? }
436
+ it { is_expected.to eq(true) }
437
+ end
438
+
439
+ describe '#additional_info_byte_count' do
440
+ subject { super().additional_info_byte_count }
441
+ it { is_expected.to eq 4 }
442
+ end
443
+
444
+ describe '#position_and_count_of_data_length_bytes' do
445
+ subject { super().position_and_count_of_data_length_bytes }
446
+ it { is_expected.to eq [0, 4] }
447
+ end
448
+
449
+ describe '#position_and_count_of_group_id_bytes' do
450
+ subject { super().position_and_count_of_group_id_bytes }
451
+ it { is_expected.to eq nil }
452
+ end
453
+
454
+ describe '#position_and_count_of_encryption_id_bytes' do
455
+ subject { super().position_and_count_of_encryption_id_bytes }
456
+ it { is_expected.to eq nil }
457
+ end
123
458
  end
124
459
 
125
460
  context "when compression and group id is on" do
126
461
  let(:flag_bytes) { [0b00000000, 0b01001001].pack("C2") }
127
- its(:preserve_on_tag_alteration?) { should be_true }
128
- its(:preserve_on_file_alteration?) { should be_true }
129
- its(:read_only?) { should be_false }
130
- its(:compressed?) { should be_true }
131
- its(:encrypted?) { should be_false }
132
- its(:grouped?) { should be_true }
133
- its(:unsynchronised?) { should be_false }
134
- its(:data_length_indicator?) { should be_true }
135
- its(:additional_info_byte_count) { should eq 5 }
136
- its(:position_and_count_of_data_length_bytes) { should eq [1, 4] }
137
- its(:position_and_count_of_group_id_bytes) { should eq [0, 1] }
138
- its(:position_and_count_of_encryption_id_bytes) { should eq nil }
462
+
463
+ describe '#preserve_on_tag_alteration?' do
464
+ subject { super().preserve_on_tag_alteration? }
465
+ it { is_expected.to eq(true) }
466
+ end
467
+
468
+ describe '#preserve_on_file_alteration?' do
469
+ subject { super().preserve_on_file_alteration? }
470
+ it { is_expected.to eq(true) }
471
+ end
472
+
473
+ describe '#read_only?' do
474
+ subject { super().read_only? }
475
+ it { is_expected.to eq(false) }
476
+ end
477
+
478
+ describe '#compressed?' do
479
+ subject { super().compressed? }
480
+ it { is_expected.to eq(true) }
481
+ end
482
+
483
+ describe '#encrypted?' do
484
+ subject { super().encrypted? }
485
+ it { is_expected.to eq(false) }
486
+ end
487
+
488
+ describe '#grouped?' do
489
+ subject { super().grouped? }
490
+ it { is_expected.to eq(true) }
491
+ end
492
+
493
+ describe '#unsynchronised?' do
494
+ subject { super().unsynchronised? }
495
+ it { is_expected.to eq(false) }
496
+ end
497
+
498
+ describe '#data_length_indicator?' do
499
+ subject { super().data_length_indicator? }
500
+ it { is_expected.to eq(true) }
501
+ end
502
+
503
+ describe '#additional_info_byte_count' do
504
+ subject { super().additional_info_byte_count }
505
+ it { is_expected.to eq 5 }
506
+ end
507
+
508
+ describe '#position_and_count_of_data_length_bytes' do
509
+ subject { super().position_and_count_of_data_length_bytes }
510
+ it { is_expected.to eq [1, 4] }
511
+ end
512
+
513
+ describe '#position_and_count_of_group_id_bytes' do
514
+ subject { super().position_and_count_of_group_id_bytes }
515
+ it { is_expected.to eq [0, 1] }
516
+ end
517
+
518
+ describe '#position_and_count_of_encryption_id_bytes' do
519
+ subject { super().position_and_count_of_encryption_id_bytes }
520
+ it { is_expected.to eq nil }
521
+ end
139
522
  end
140
523
 
141
524
  context "when all flags are 1" do
142
525
  let(:flag_bytes) { [0b01110000, 0b01001111].pack("C2") }
143
- its(:preserve_on_tag_alteration?) { should be_false }
144
- its(:preserve_on_file_alteration?) { should be_false }
145
- its(:read_only?) { should be_true }
146
- its(:compressed?) { should be_true }
147
- its(:encrypted?) { should be_true }
148
- its(:grouped?) { should be_true }
149
- its(:unsynchronised?) { should be_true }
150
- its(:data_length_indicator?) { should be_true }
151
- its(:additional_info_byte_count) { should eq 6 }
152
- its(:position_and_count_of_data_length_bytes) { should eq [2, 4] }
153
- its(:position_and_count_of_group_id_bytes) { should eq [0, 1] }
154
- its(:position_and_count_of_encryption_id_bytes) { should eq [1, 1] }
526
+
527
+ describe '#preserve_on_tag_alteration?' do
528
+ subject { super().preserve_on_tag_alteration? }
529
+ it { is_expected.to eq(false) }
530
+ end
531
+
532
+ describe '#preserve_on_file_alteration?' do
533
+ subject { super().preserve_on_file_alteration? }
534
+ it { is_expected.to eq(false) }
535
+ end
536
+
537
+ describe '#read_only?' do
538
+ subject { super().read_only? }
539
+ it { is_expected.to eq(true) }
540
+ end
541
+
542
+ describe '#compressed?' do
543
+ subject { super().compressed? }
544
+ it { is_expected.to eq(true) }
545
+ end
546
+
547
+ describe '#encrypted?' do
548
+ subject { super().encrypted? }
549
+ it { is_expected.to eq(true) }
550
+ end
551
+
552
+ describe '#grouped?' do
553
+ subject { super().grouped? }
554
+ it { is_expected.to eq(true) }
555
+ end
556
+
557
+ describe '#unsynchronised?' do
558
+ subject { super().unsynchronised? }
559
+ it { is_expected.to eq(true) }
560
+ end
561
+
562
+ describe '#data_length_indicator?' do
563
+ subject { super().data_length_indicator? }
564
+ it { is_expected.to eq(true) }
565
+ end
566
+
567
+ describe '#additional_info_byte_count' do
568
+ subject { super().additional_info_byte_count }
569
+ it { is_expected.to eq 6 }
570
+ end
571
+
572
+ describe '#position_and_count_of_data_length_bytes' do
573
+ subject { super().position_and_count_of_data_length_bytes }
574
+ it { is_expected.to eq [2, 4] }
575
+ end
576
+
577
+ describe '#position_and_count_of_group_id_bytes' do
578
+ subject { super().position_and_count_of_group_id_bytes }
579
+ it { is_expected.to eq [0, 1] }
580
+ end
581
+
582
+ describe '#position_and_count_of_encryption_id_bytes' do
583
+ subject { super().position_and_count_of_encryption_id_bytes }
584
+ it { is_expected.to eq [1, 1] }
585
+ end
155
586
  end
156
587
  end
157
588
  end