flac2mp3 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ == 0.4.0 2009-09-22
2
+
3
+ * 1 enhancement:
4
+ * Converting UTF-8 FLAC tag data to ISO-8859-1 MP3 data for good iTunes display
5
+ * 1 change:
6
+ * Switched tests from rspec/mocha to bacon/facon
7
+
1
8
  == 0.3.2 2008-11-29
2
9
 
3
10
  * 3 enhancements:
@@ -16,9 +16,7 @@ setup.rb
16
16
  spec/flac2mp3_command_spec.rb
17
17
  spec/flac2mp3_spec.rb
18
18
  spec/metaflac2mp3_command_spec.rb
19
- spec/spec.opts
20
19
  spec/spec_helper.rb
21
20
  tasks/deployment.rake
22
21
  tasks/environment.rake
23
- tasks/rspec.rake
24
22
  tasks/website.rake
@@ -12,8 +12,8 @@ EXTRA_DEPENDENCIES = [
12
12
  ['ruby-mp3info', '>= 0.5.1']
13
13
  ] # An array of rubygem dependencies [name, version]
14
14
  EXTRA_DEV_DEPENDENCIES = [
15
- ['rspec', '>= 1.1.4'],
16
- ['mocha', '>= 0.9.1']
15
+ ['bacon', '>= 1.1.0'],
16
+ ['facon', '>= 0.4.1']
17
17
  ] # An array of rubygem dependencies [name, version]
18
18
 
19
19
  @config_file = "~/.rubyforge/user-config.yml"
@@ -2,10 +2,10 @@ $:.unshift File.dirname(__FILE__)
2
2
  require 'flacinfo'
3
3
  require 'mp3info'
4
4
  require 'yaml'
5
+ require 'iconv'
5
6
 
6
7
  class Flac2mp3
7
8
  def initialize(options = {})
8
- @config = {}
9
9
  load_config
10
10
  set_options(options)
11
11
  end
@@ -49,6 +49,7 @@ class Flac2mp3
49
49
  key = key.to_s.downcase.to_sym
50
50
  value = value.to_i if value.respond_to?(:match) and value.match(/^\d+$/)
51
51
  value = value.to_s if self.class.string_fields.include?(key)
52
+ value = Iconv.conv('ISO-8859-1//TRANSLIT', 'UTF-8', value) if value.is_a?(String)
52
53
 
53
54
  hash[key] = value
54
55
  hash
@@ -66,13 +67,10 @@ class Flac2mp3
66
67
  end
67
68
 
68
69
  def load_config
70
+ @config = {}
69
71
  yaml = YAML.load(File.read(File.expand_path('~/.flac2mp3'))) || {}
70
- @config = yaml.inject({}) do |hash, (key, value)|
71
- hash[key.to_sym] = value
72
- hash
73
- end
72
+ yaml.each { |k, v| @config[k.to_sym] = v }
74
73
  rescue Errno::ENOENT
75
- @config = {}
76
74
  end
77
75
 
78
76
  def set_options(options)
@@ -1,8 +1,8 @@
1
1
  class Flac2mp3 #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 3
5
- TINY = 2
4
+ MINOR = 4
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,18 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe 'flac2mp3 command' do
4
- def run_command(*args)
5
- Object.const_set(:ARGV, args)
6
- begin
7
- eval File.read(File.join(File.dirname(__FILE__), *%w[.. bin flac2mp3]))
8
- rescue SystemExit
9
- end
3
+ def run_command(*args)
4
+ Object.const_set(:ARGV, args)
5
+ begin
6
+ eval File.read(File.join(File.dirname(__FILE__), *%w[.. bin flac2mp3]))
7
+ rescue SystemExit
10
8
  end
11
-
12
- before :each do
13
- @convert_state = states('convert').starts_as('setup')
14
- Flac2mp3.stubs(:convert).when(@convert_state.is('setup'))
15
- Flac2mp3.stubs(:convert_metadata)
9
+ end
10
+
11
+ describe 'flac2mp3 command' do
12
+ before do
13
+ Flac2mp3.stub!(:convert)
14
+ Flac2mp3.stub!(:convert_metadata)
16
15
 
17
16
  [:ARGV, :OPTIONS, :MANDATORY_OPTIONS].each do |const|
18
17
  Object.send(:remove_const, const) if Object.const_defined?(const)
@@ -20,97 +19,122 @@ describe 'flac2mp3 command' do
20
19
  end
21
20
 
22
21
  it 'should exist' do
23
- lambda { run_command('blah') }.should_not raise_error(Errno::ENOENT)
22
+ lambda { run_command('blah') }.should.not.raise(Errno::ENOENT)
24
23
  end
25
24
 
26
25
  it 'should require a filename' do
27
- self.expects(:puts) { |text| text.match(/usage.+filename/i) }
26
+ self.should.receive(:puts) do |output|
27
+ output.should.match(/usage.+filename/i)
28
+ end
28
29
  run_command
29
30
  end
30
31
 
31
32
  it 'should pass the filename to Flac2mp3 for conversion' do
32
- Flac2mp3.expects(:convert).with('blah', anything)
33
+ Flac2mp3.should.receive(:convert) do |filename, _|
34
+ filename.should == 'blah'
35
+ end
33
36
  run_command('blah')
34
37
  end
35
38
 
36
39
  it 'should pass on a true flac-deletion option if specified on the command line (using --delete)' do
37
- Flac2mp3.expects(:convert).with(anything, has_entry(:delete => true))
40
+ Flac2mp3.should.receive(:convert) do |_, options|
41
+ options[:delete].should == true
42
+ end
38
43
  run_command('blah', '--delete')
39
44
  end
40
45
 
41
46
  it 'should pass on a false flac-deletion option if specified on the command line (using --no-delete)' do
42
- Flac2mp3.expects(:convert).with(anything, has_entry(:delete => false))
47
+ Flac2mp3.should.receive(:convert) do |_, options|
48
+ options[:delete].should == false
49
+ end
43
50
  run_command('blah', '--no-delete')
44
51
  end
45
52
 
46
53
  it 'should pass on a true flac-deletion option if specified on the command line (using -d)' do
47
- Flac2mp3.expects(:convert).with(anything, has_entry(:delete => true))
54
+ Flac2mp3.should.receive(:convert) do |_, options|
55
+ options[:delete].should == true
56
+ end
48
57
  run_command('blah', '-d')
49
58
  end
50
59
 
51
60
  it 'should not pass on any flac-deletion option if nothing specified on the command line' do
52
- Flac2mp3.expects(:convert).with(anything, Not(has_key(:delete)))
61
+ Flac2mp3.should.receive(:convert) do |_, options|
62
+ options.should.not.include(:delete)
63
+ end
53
64
  run_command('blah')
54
65
  end
55
66
 
56
67
  it 'should pass on a true silence option if specified on the command line (using --silent)' do
57
- Flac2mp3.expects(:convert).with(anything, has_entry(:silent => true))
68
+ Flac2mp3.should.receive(:convert) do |_, options|
69
+ options[:silent].should == true
70
+ end
58
71
  run_command('blah', '--silent')
59
72
  end
60
73
 
61
74
  it 'should pass on a true silence option if specified on the command line (using -s)' do
62
- Flac2mp3.expects(:convert).with(anything, has_entry(:silent => true))
75
+ Flac2mp3.should.receive(:convert) do |_, options|
76
+ options[:silent].should == true
77
+ end
63
78
  run_command('blah', '-s')
64
79
  end
65
80
 
66
81
  it 'should not pass on any silence option if nothing specified on the command line' do
67
- Flac2mp3.expects(:convert).with(anything, Not(has_key(:silent)))
82
+ Flac2mp3.should.receive(:convert) do |_, options|
83
+ options.should.not.include(:silent)
84
+ end
68
85
  run_command('blah')
69
86
  end
70
87
 
71
88
  it 'should pass on the encoding option specified on the command line' do
72
- Flac2mp3.expects(:convert).with(anything, has_entry(:encoding => '--preset fast standard'))
89
+ Flac2mp3.should.receive(:convert) do |_, options|
90
+ options[:encoding].should == '--preset fast standard'
91
+ end
73
92
  run_command('blah', '--encoding', '--preset fast standard')
74
93
  end
75
94
 
76
95
  it 'should pass on the encoding option specified in shorthand on the command line' do
77
- Flac2mp3.expects(:convert).with(anything, has_entry(:encoding => '--preset fast standard'))
96
+ Flac2mp3.should.receive(:convert) do |_, options|
97
+ options[:encoding].should == '--preset fast standard'
98
+ end
78
99
  run_command('blah', '-e', '--preset fast standard')
79
100
  end
80
101
 
81
102
  it 'should pass on no encoding option if none specified on the command line' do
82
- Flac2mp3.expects(:convert).with(anything, Not(has_key(:encoding)))
103
+ Flac2mp3.should.receive(:convert) do |_, options|
104
+ options.should.not.include(:encoding)
105
+ end
83
106
  run_command('blah')
84
107
  end
85
108
 
86
109
  it 'should take a --meta option to convert metadata' do
87
- lambda { run_command('--meta', 'blah.flac', 'something.mp3') }.should_not raise_error(OptionParser::InvalidOption)
110
+ lambda { run_command('--meta', 'blah.flac', 'something.mp3') }.should.not.raise(OptionParser::InvalidOption)
88
111
  end
89
112
 
90
113
  describe 'when converting metadata' do
91
- before :each do
114
+ before do
92
115
  @infile = 'blah.flac'
93
116
  @outfile = 'something.mp3'
94
117
  end
95
118
 
96
119
  it 'should require two filenames' do
97
- self.expects(:puts) { |text| text.match(/usage.+filename/i) }
120
+ self.should.receive(:puts) do |output|
121
+ output.should.match(/usage.+filename/i)
122
+ end
98
123
  run_command('--meta', @infile)
99
124
  end
100
125
 
101
126
  it 'should pass the filenames to Flac2mp3 for metadata conversion' do
102
- Flac2mp3.expects(:convert_metadata).with(@infile, @outfile)
127
+ Flac2mp3.should.receive(:convert_metadata).with(@infile, @outfile)
103
128
  run_command('--meta', @infile, @outfile)
104
129
  end
105
130
 
106
131
  it 'should not attempt to convert any files' do
107
- @convert_state.become('test')
108
- Flac2mp3.expects(:convert).never.when(@convert_state.is('test'))
132
+ Flac2mp3.should.receive(:convert).never
109
133
  run_command('--meta', @infile, @outfile)
110
134
  end
111
135
 
112
136
  it 'should accept a shorthand -m option' do
113
- Flac2mp3.expects(:convert_metadata).with(@infile, @outfile)
137
+ Flac2mp3.should.receive(:convert_metadata).with(@infile, @outfile)
114
138
  run_command('-m', @infile, @outfile)
115
139
  end
116
140
  end
@@ -1,58 +1,79 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe Flac2mp3 do
4
- before :each do
4
+ before do
5
5
  @flac2mp3 = Flac2mp3.new
6
6
  end
7
7
 
8
8
  describe 'when initialized' do
9
- before :each do
9
+ before do
10
10
  @options = { :silent => true, :delete => false }
11
11
  end
12
12
 
13
13
  it 'should accept options' do
14
- lambda { Flac2mp3.new(@options) }.should_not raise_error(ArgumentError)
14
+ lambda { Flac2mp3.new(@options) }.should.not.raise(ArgumentError)
15
15
  end
16
16
 
17
17
  it 'should not require options' do
18
- lambda { Flac2mp3.new }.should_not raise_error(ArgumentError)
19
- end
20
-
21
- it 'should load the configuration' do
22
- Flac2mp3.any_instance.expects(:load_config)
23
- Flac2mp3.new
24
- end
25
-
26
- it 'should set the options' do
27
- Flac2mp3.any_instance.expects(:set_options).with(@options)
28
- Flac2mp3.new(@options)
29
- end
30
-
31
- it 'should default to empty options' do
32
- Flac2mp3.any_instance.expects(:set_options).with({})
33
- Flac2mp3.new
18
+ lambda { Flac2mp3.new }.should.not.raise(ArgumentError)
19
+ end
20
+
21
+ describe do
22
+ # unnamed describe block just to give a level of organization
23
+ # to this subclass-based initialize-behavior testing
24
+ before do
25
+ @subclass = Class.new(Flac2mp3) do
26
+ attr_reader :config_loaded, :options_set, :options
27
+
28
+ def load_config
29
+ @config_loaded = true
30
+ end
31
+
32
+ def set_options(*args)
33
+ @options_set = true
34
+ @options = args
35
+ end
36
+ end
37
+ end
38
+
39
+ it 'should load the configuration' do
40
+ obj = @subclass.new
41
+ obj.config_loaded.should == true
42
+ end
43
+
44
+ it 'should set the options' do
45
+ obj = @subclass.new(@options)
46
+ obj.options_set.should == true
47
+ obj.options.should == [@options]
48
+ end
49
+
50
+ it 'should default to empty options' do
51
+ obj = @subclass.new
52
+ obj.options_set.should == true
53
+ obj.options.should == [{}]
54
+ end
34
55
  end
35
56
  end
36
57
 
37
58
  it 'should load the configuration' do
38
- @flac2mp3.should respond_to(:load_config)
59
+ @flac2mp3.should.respond_to(:load_config)
39
60
  end
40
61
 
41
62
  describe 'loading the configuration' do
42
63
  it 'should look for a config file' do
43
- File.expects(:read).with(File.expand_path('~/.flac2mp3')).returns('')
64
+ File.should.receive(:read).with(File.expand_path('~/.flac2mp3')).and_return('')
44
65
  @flac2mp3.load_config
45
66
  end
46
67
 
47
68
  describe 'when a config file is found' do
48
- before :each do
69
+ before do
49
70
  @config = { :silent => true, :delete => false }
50
71
  @contents = @config.to_yaml
51
- File.stubs(:read).returns(@contents)
72
+ File.stub!(:read).and_return(@contents)
52
73
  end
53
74
 
54
75
  it 'should parse the file as YAML' do
55
- YAML.expects(:load).with(@contents)
76
+ YAML.should.receive(:load).with(@contents)
56
77
  @flac2mp3.load_config
57
78
  end
58
79
 
@@ -62,13 +83,13 @@ describe Flac2mp3 do
62
83
  end
63
84
 
64
85
  it 'should convert string keys to symbols' do
65
- File.stubs(:read).returns({ 'silent' => true, 'delete' => false }.to_yaml)
86
+ File.stub!(:read).and_return({ 'silent' => true, 'delete' => false }.to_yaml)
66
87
  @flac2mp3.load_config
67
88
  @flac2mp3.config.should == @config
68
89
  end
69
90
 
70
91
  it 'should handle an empty file' do
71
- File.stubs(:read).returns('')
92
+ File.stub!(:read).and_return('')
72
93
  @flac2mp3.load_config
73
94
  @flac2mp3.config.should == {}
74
95
  end
@@ -81,8 +102,8 @@ describe Flac2mp3 do
81
102
  end
82
103
 
83
104
  describe 'when no config file is found' do
84
- before :each do
85
- File.stubs(:read).raises(Errno::ENOENT)
105
+ before do
106
+ File.stub!(:read).and_raise(Errno::ENOENT)
86
107
  end
87
108
 
88
109
  it 'should store an empty config' do
@@ -92,28 +113,28 @@ describe Flac2mp3 do
92
113
  end
93
114
 
94
115
  it 'should set options' do
95
- @flac2mp3.should respond_to(:set_options)
116
+ @flac2mp3.should.respond_to(:set_options)
96
117
  end
97
118
 
98
119
  describe 'setting options' do
99
- before :each do
120
+ before do
100
121
  @options = { :silent => true, :delete => false }
101
122
  end
102
123
 
103
124
  it 'should accept options' do
104
- lambda { @flac2mp3.set_options(:silent => true) }.should_not raise_error(ArgumentError)
125
+ lambda { @flac2mp3.set_options(:silent => true) }.should.not.raise(ArgumentError)
105
126
  end
106
127
 
107
128
  it 'should require options' do
108
- lambda { @flac2mp3.set_options }.should raise_error(ArgumentError)
129
+ lambda { @flac2mp3.set_options }.should.raise(ArgumentError)
109
130
  end
110
131
 
111
132
  it 'should accept a hash of options' do
112
- lambda { @flac2mp3.set_options(:silent => true) }.should_not raise_error(TypeError)
133
+ lambda { @flac2mp3.set_options(:silent => true) }.should.not.raise(TypeError)
113
134
  end
114
135
 
115
136
  it 'should require a hash of options' do
116
- lambda { @flac2mp3.set_options('silent') }.should raise_error(TypeError)
137
+ lambda { @flac2mp3.set_options('silent') }.should.raise(TypeError)
117
138
  end
118
139
 
119
140
  it 'should store the options' do
@@ -129,39 +150,39 @@ describe Flac2mp3 do
129
150
  end
130
151
 
131
152
  describe 'querying options' do
132
- before :each do
133
- File.stubs(:read).returns('')
153
+ before do
154
+ File.stub!(:read).and_return('')
134
155
  @flac2mp3.load_config
135
156
  end
136
157
 
137
158
  it 'should indicate the original file should be deleted when a true option is given' do
138
159
  @flac2mp3.set_options(:delete => true)
139
- @flac2mp3.delete?.should be(true)
160
+ @flac2mp3.delete?.should == true
140
161
  end
141
162
 
142
163
  it 'should indicate the original file should not be deleted when a false option is given' do
143
164
  @flac2mp3.set_options(:delete => false)
144
- @flac2mp3.delete?.should be(false)
165
+ @flac2mp3.delete?.should == false
145
166
  end
146
167
 
147
168
  it 'should indicate the original file should not be deleted when no option is given' do
148
169
  @flac2mp3.set_options({})
149
- @flac2mp3.delete?.should be(false)
170
+ @flac2mp3.delete?.should == false
150
171
  end
151
172
 
152
173
  it 'should indicate the conversion should be silent when a true option is given' do
153
174
  @flac2mp3.set_options(:silent => true)
154
- @flac2mp3.silent?.should be(true)
175
+ @flac2mp3.silent?.should == true
155
176
  end
156
177
 
157
178
  it 'should indicate the conversion should not be silent when a false option is given' do
158
179
  @flac2mp3.set_options(:silent => false)
159
- @flac2mp3.silent?.should be(false)
180
+ @flac2mp3.silent?.should == false
160
181
  end
161
182
 
162
183
  it 'should indicate the conversion should not be silent when no option is given' do
163
184
  @flac2mp3.set_options({})
164
- @flac2mp3.silent?.should be(false)
185
+ @flac2mp3.silent?.should == false
165
186
  end
166
187
 
167
188
  it 'should store the given encoding' do
@@ -177,150 +198,151 @@ describe Flac2mp3 do
177
198
 
178
199
  it 'should use values from the configuration' do
179
200
  config = {:silent => true}
180
- File.stubs(:read).returns(config.to_yaml)
181
- Flac2mp3.new.silent?.should be(true)
201
+ File.stub!(:read).and_return(config.to_yaml)
202
+ Flac2mp3.new.silent?.should == true
182
203
  end
183
204
 
184
205
  it 'should override configuration values with options' do
185
206
  config = {:silent => true}
186
- File.stubs(:read).returns(config.to_yaml)
187
- Flac2mp3.new(:silent => false).silent?.should be(false)
207
+ File.stub!(:read).and_return(config.to_yaml)
208
+ Flac2mp3.new(:silent => false).silent?.should == false
188
209
  end
189
210
 
190
211
  it 'should combine configuration and option values' do
191
212
  config = {:silent => true}
192
- File.stubs(:read).returns(config.to_yaml)
213
+ File.stub!(:read).and_return(config.to_yaml)
193
214
  flac2mp3 = Flac2mp3.new(:delete => true)
194
215
 
195
- flac2mp3.silent?.should be(true)
196
- flac2mp3.delete?.should be(true)
216
+ flac2mp3.silent?.should == true
217
+ flac2mp3.delete?.should == true
197
218
  end
198
219
  end
199
220
 
200
221
  it 'should convert' do
201
- @flac2mp3.should respond_to(:convert)
222
+ @flac2mp3.should.respond_to(:convert)
202
223
  end
203
224
 
204
225
  describe 'when converting' do
205
- before :each do
226
+ before do
206
227
  @filename = 'test.flac'
207
- @flac2mp3.stubs(:process_conversion)
228
+ @flac2mp3.stub!(:process_conversion)
229
+ FileTest.stub!(:file?).and_return(true)
208
230
  end
209
231
 
210
232
  it 'should accept a filename' do
211
- lambda { @flac2mp3.convert(@filename) }.should_not raise_error(ArgumentError)
233
+ lambda { @flac2mp3.convert(@filename) }.should.not.raise(ArgumentError)
212
234
  end
213
235
 
214
236
  it 'should require a filename' do
215
- lambda { @flac2mp3.convert }.should raise_error(ArgumentError)
237
+ lambda { @flac2mp3.convert }.should.raise(ArgumentError)
216
238
  end
217
239
 
218
240
  it 'should check if the filename belongs to a regular file' do
219
- FileTest.expects(:file?).with(@filename).returns(true)
241
+ FileTest.should.receive(:file?).with(@filename).and_return(true)
220
242
  @flac2mp3.convert(@filename)
221
243
  end
222
244
 
223
245
  describe 'when given a filename belonging to a regular file' do
224
- before :each do
225
- FileTest.stubs(:file?).returns(true)
246
+ before do
247
+ FileTest.stub!(:file?).and_return(true)
226
248
  end
227
249
 
228
250
  it 'should not error' do
229
- lambda { @flac2mp3.convert(@filename) }.should_not raise_error(TypeError)
251
+ lambda { @flac2mp3.convert(@filename) }.should.not.raise(TypeError)
230
252
  end
231
253
 
232
254
  it 'should process the conversion' do
233
- @flac2mp3.expects(:process_conversion).with(@filename)
255
+ @flac2mp3.should.receive(:process_conversion).with(@filename)
234
256
  @flac2mp3.convert(@filename)
235
257
  end
236
258
 
237
259
  it 'should check if the original file should be deleted' do
238
- @flac2mp3.expects(:delete?)
260
+ @flac2mp3.should.receive(:delete?)
239
261
  @flac2mp3.convert(@filename)
240
262
  end
241
263
 
242
264
  describe 'when the original file should be deleted' do
243
- before :each do
244
- @flac2mp3.stubs(:delete?).returns(true)
265
+ before do
266
+ @flac2mp3.stub!(:delete?).and_return(true)
245
267
  end
246
268
 
247
269
  it 'should delete the original file' do
248
- File.expects(:delete).with(@filename)
270
+ File.should.receive(:delete).with(@filename)
249
271
  @flac2mp3.convert(@filename)
250
272
  end
251
273
  end
252
274
 
253
275
  describe 'when the original file should not be deleted' do
254
- before :each do
255
- @flac2mp3.stubs(:delete?).returns(false)
276
+ before do
277
+ @flac2mp3.stub!(:delete?).and_return(false)
256
278
  end
257
279
 
258
280
  it 'should not delete the original file' do
259
- File.expects(:delete).never
281
+ File.should.receive(:delete).never
260
282
  @flac2mp3.convert(@filename)
261
283
  end
262
284
  end
263
285
  end
264
286
 
265
287
  describe 'when given a filename not belonging to a regular file' do
266
- before :each do
267
- FileTest.stubs(:file?).returns(false)
288
+ before do
289
+ FileTest.stub!(:file?).and_return(false)
268
290
  end
269
291
 
270
292
  it 'should error' do
271
- lambda { @flac2mp3.convert(@filename) }.should raise_error(TypeError)
293
+ lambda { @flac2mp3.convert(@filename) }.should.raise(TypeError)
272
294
  end
273
295
  end
274
296
  end
275
297
 
276
298
  it 'should process conversion' do
277
- @flac2mp3.should respond_to(:process_conversion)
299
+ @flac2mp3.should.respond_to(:process_conversion)
278
300
  end
279
301
 
280
302
  describe 'when processing conversion' do
281
- before :each do
303
+ before do
282
304
  @filename = 'test.flac'
283
305
  @out_filename = 'test.mp3'
284
- @flac2mp3.stubs(:output_filename).returns(@out_filename)
285
- @flac2mp3.stubs(:convert_data)
286
- @flac2mp3.stubs(:convert_metadata)
306
+ @flac2mp3.stub!(:output_filename).and_return(@out_filename)
307
+ @flac2mp3.stub!(:convert_data)
308
+ @flac2mp3.stub!(:convert_metadata)
287
309
  end
288
310
 
289
311
  it 'should accept a filename' do
290
- lambda { @flac2mp3.process_conversion(@filename) }.should_not raise_error(ArgumentError)
312
+ lambda { @flac2mp3.process_conversion(@filename) }.should.not.raise(ArgumentError)
291
313
  end
292
314
 
293
315
  it 'should require a filename' do
294
- lambda { @flac2mp3.process_conversion }.should raise_error(ArgumentError)
316
+ lambda { @flac2mp3.process_conversion }.should.raise(ArgumentError)
295
317
  end
296
318
 
297
319
  it 'get the output filename from the given filename' do
298
- @flac2mp3.expects(:output_filename).with(@filename)
320
+ @flac2mp3.should.receive(:output_filename).with(@filename)
299
321
  @flac2mp3.process_conversion(@filename)
300
322
  end
301
323
 
302
324
  it 'should convert data' do
303
- @flac2mp3.expects(:convert_data).with(@filename, @out_filename)
325
+ @flac2mp3.should.receive(:convert_data).with(@filename, @out_filename)
304
326
  @flac2mp3.process_conversion(@filename)
305
327
  end
306
328
 
307
329
  it 'should convert metadata' do
308
- @flac2mp3.expects(:convert_metadata).with(@filename, @out_filename)
330
+ @flac2mp3.should.receive(:convert_metadata).with(@filename, @out_filename)
309
331
  @flac2mp3.process_conversion(@filename)
310
332
  end
311
333
  end
312
334
 
313
335
  it 'should provide an output filename' do
314
- @flac2mp3.should respond_to(:output_filename)
336
+ @flac2mp3.should.respond_to(:output_filename)
315
337
  end
316
338
 
317
339
  describe 'providing an output filename' do
318
340
  it 'should accept a filename' do
319
- lambda { @flac2mp3.output_filename('blah.flac') }.should_not raise_error(ArgumentError)
341
+ lambda { @flac2mp3.output_filename('blah.flac') }.should.not.raise(ArgumentError)
320
342
  end
321
343
 
322
344
  it 'should require a filename' do
323
- lambda { @flac2mp3.output_filename }.should raise_error(ArgumentError)
345
+ lambda { @flac2mp3.output_filename }.should.raise(ArgumentError)
324
346
  end
325
347
 
326
348
  it 'should convert a .flac extension to an .mp3 extension' do
@@ -333,81 +355,81 @@ describe Flac2mp3 do
333
355
  end
334
356
 
335
357
  it 'should convert data' do
336
- @flac2mp3.should respond_to(:convert_data)
358
+ @flac2mp3.should.respond_to(:convert_data)
337
359
  end
338
360
 
339
361
  describe 'when converting data' do
340
- before :each do
362
+ before do
341
363
  @filename = 'test.flac'
342
364
  @out_filename = 'test.mp3'
343
365
  @flac_command = 'flac command'
344
366
  @mp3_command = 'mp3 command'
345
- @flac2mp3.stubs(:flac_command).returns(@flac_command)
346
- @flac2mp3.stubs(:mp3_command).returns(@mp3_command)
347
- @flac2mp3.stubs(:system)
367
+ @flac2mp3.stub!(:flac_command).and_return(@flac_command)
368
+ @flac2mp3.stub!(:mp3_command).and_return(@mp3_command)
369
+ @flac2mp3.stub!(:system)
348
370
  end
349
371
 
350
372
  it 'should accept a filename and an output filename' do
351
- lambda { @flac2mp3.convert_data(@filename, @out_filename) }.should_not raise_error(ArgumentError)
373
+ lambda { @flac2mp3.convert_data(@filename, @out_filename) }.should.not.raise(ArgumentError)
352
374
  end
353
375
 
354
376
  it 'should require an output filename' do
355
- lambda { @flac2mp3.convert_data(@filename) }.should raise_error(ArgumentError)
377
+ lambda { @flac2mp3.convert_data(@filename) }.should.raise(ArgumentError)
356
378
  end
357
379
 
358
380
  it 'should require a filename' do
359
- lambda { @flac2mp3.convert_data }.should raise_error(ArgumentError)
381
+ lambda { @flac2mp3.convert_data }.should.raise(ArgumentError)
360
382
  end
361
383
 
362
384
  it 'should call the flac command with the given filename' do
363
- @flac2mp3.expects(:flac_command).with(@filename)
385
+ @flac2mp3.should.receive(:flac_command).with(@filename)
364
386
  @flac2mp3.convert_data(@filename, @out_filename)
365
387
  end
366
388
 
367
389
  it 'should call the mp3 command with the given output filename' do
368
- @flac2mp3.expects(:mp3_command).with(@out_filename)
390
+ @flac2mp3.should.receive(:mp3_command).with(@out_filename)
369
391
  @flac2mp3.convert_data(@filename, @out_filename)
370
392
  end
371
393
 
372
394
  it 'should shell out to the system with the flac and mp3 commands' do
373
- @flac2mp3.expects(:system).with("#{@flac_command} | #{@mp3_command}")
395
+ @flac2mp3.should.receive(:system).with("#{@flac_command} | #{@mp3_command}")
374
396
  @flac2mp3.convert_data(@filename, @out_filename)
375
397
  end
376
398
  end
377
399
 
378
400
  it 'should provide a flac command' do
379
- @flac2mp3.should respond_to(:flac_command)
401
+ @flac2mp3.should.respond_to(:flac_command)
380
402
  end
381
403
 
382
404
  describe 'when providing a flac command' do
383
- before :each do
405
+ before do
384
406
  @filename = 'test.flac'
385
407
  @safe_filename = 'safetest.safeflac'
386
- @flac2mp3.stubs(:safequote).returns(@safe_filename)
387
- @flac2mp3.stubs(:silent?)
408
+ @flac2mp3.stub!(:safequote).and_return(@safe_filename)
409
+ @flac2mp3.stub!(:silent?)
388
410
  end
389
411
 
390
412
  it 'should accept a filename' do
391
- lambda { @flac2mp3.flac_command(@filename) }.should_not raise_error(ArgumentError)
413
+ lambda { @flac2mp3.flac_command(@filename) }.should.not.raise(ArgumentError)
392
414
  end
393
415
 
394
416
  it 'should require a filename' do
395
- lambda { @flac2mp3.flac_command }.should raise_error(ArgumentError)
417
+ lambda { @flac2mp3.flac_command }.should.raise(ArgumentError)
396
418
  end
397
419
 
398
420
  it 'should safequote the filename' do
399
- @flac2mp3.expects(:safequote).with(@filename)
421
+ @flac2mp3.should.receive(:safequote).with(@filename)
400
422
  @flac2mp3.flac_command(@filename)
401
423
  end
402
424
 
403
425
  it 'should check if the command should be silent' do
404
- @flac2mp3.expects(:silent?)
426
+ @flac2mp3.should.receive(:silent?)
405
427
  @flac2mp3.flac_command(@filename)
406
428
  end
407
429
 
408
430
  describe 'when the command should be silent' do
409
- before :each do
410
- @flac2mp3.stubs(:silent?).returns(true)
431
+ before do
432
+ @flac2mp3.stub!(:silent?).and_return(true)
411
433
  end
412
434
 
413
435
  it 'should provide a flac shell command that will be silent' do
@@ -416,8 +438,8 @@ describe Flac2mp3 do
416
438
  end
417
439
 
418
440
  describe 'when the command should not be silent' do
419
- before :each do
420
- @flac2mp3.stubs(:silent?).returns(false)
441
+ before do
442
+ @flac2mp3.stub!(:silent?).and_return(false)
421
443
  end
422
444
 
423
445
  it 'should provide a flac shell command that will not be silent' do
@@ -427,45 +449,45 @@ describe Flac2mp3 do
427
449
  end
428
450
 
429
451
  it 'should provide an mp3 command' do
430
- @flac2mp3.should respond_to(:mp3_command)
452
+ @flac2mp3.should.respond_to(:mp3_command)
431
453
  end
432
454
 
433
455
  describe 'when providing an mp3 command' do
434
- before :each do
456
+ before do
435
457
  @filename = 'test.mp3'
436
458
  @safe_filename = 'safetest.safemp3'
437
- @flac2mp3.stubs(:safequote).returns(@safe_filename)
438
- @flac2mp3.stubs(:silent?)
459
+ @flac2mp3.stub!(:safequote).and_return(@safe_filename)
460
+ @flac2mp3.stub!(:silent?)
439
461
  @encoding = '--VAWESOME'
440
- @flac2mp3.stubs(:encoding).returns(@encoding)
462
+ @flac2mp3.stub!(:encoding).and_return(@encoding)
441
463
  end
442
464
 
443
465
  it 'should accept a filename' do
444
- lambda { @flac2mp3.mp3_command(@filename) }.should_not raise_error(ArgumentError)
466
+ lambda { @flac2mp3.mp3_command(@filename) }.should.not.raise(ArgumentError)
445
467
  end
446
468
 
447
469
  it 'should require a filename' do
448
- lambda { @flac2mp3.mp3_command }.should raise_error(ArgumentError)
470
+ lambda { @flac2mp3.mp3_command }.should.raise(ArgumentError)
449
471
  end
450
472
 
451
473
  it 'should safequote the filename' do
452
- @flac2mp3.expects(:safequote).with(@filename)
474
+ @flac2mp3.should.receive(:safequote).with(@filename)
453
475
  @flac2mp3.mp3_command(@filename)
454
476
  end
455
477
 
456
478
  it 'should check if the command should be silent' do
457
- @flac2mp3.expects(:silent?)
479
+ @flac2mp3.should.receive(:silent?)
458
480
  @flac2mp3.mp3_command(@filename)
459
481
  end
460
482
 
461
483
  it 'should check the encoding to use' do
462
- @flac2mp3.expects(:encoding)
484
+ @flac2mp3.should.receive(:encoding)
463
485
  @flac2mp3.mp3_command(@filename)
464
486
  end
465
487
 
466
488
  describe 'when the command should be silent' do
467
- before :each do
468
- @flac2mp3.stubs(:silent?).returns(true)
489
+ before do
490
+ @flac2mp3.stub!(:silent?).and_return(true)
469
491
  end
470
492
 
471
493
  it 'should provide an mp3 shell command that will be silent' do
@@ -474,8 +496,8 @@ describe Flac2mp3 do
474
496
  end
475
497
 
476
498
  describe 'when the command should not be silent' do
477
- before :each do
478
- @flac2mp3.stubs(:silent?).returns(false)
499
+ before do
500
+ @flac2mp3.stub!(:silent?).and_return(false)
479
501
  end
480
502
 
481
503
  it 'should provide an mp3 shell command that will not be silent' do
@@ -485,16 +507,16 @@ describe Flac2mp3 do
485
507
  end
486
508
 
487
509
  it 'should quote filenames safely' do
488
- @flac2mp3.should respond_to(:safequote)
510
+ @flac2mp3.should.respond_to(:safequote)
489
511
  end
490
512
 
491
513
  describe 'when quoting a filename safely' do
492
514
  it 'should accept a filename' do
493
- lambda { @flac2mp3.safequote('test.flac') }.should_not raise_error(ArgumentError)
515
+ lambda { @flac2mp3.safequote('test.flac') }.should.not.raise(ArgumentError)
494
516
  end
495
517
 
496
518
  it 'should require a filename' do
497
- lambda { @flac2mp3.safequote }.should raise_error(ArgumentError)
519
+ lambda { @flac2mp3.safequote }.should.raise(ArgumentError)
498
520
  end
499
521
 
500
522
  it 'should leave alphanumeric characters alone' do
@@ -507,68 +529,68 @@ describe Flac2mp3 do
507
529
  end
508
530
 
509
531
  it 'should convert metadata' do
510
- @flac2mp3.should respond_to(:convert_metadata)
532
+ @flac2mp3.should.respond_to(:convert_metadata)
511
533
  end
512
534
 
513
535
  describe 'when converting metadata' do
514
- before :each do
536
+ before do
515
537
  @filename = 'test.flac'
516
538
  @out_filename = 'test.mp3'
517
- @flacdata = stub('flacdata')
518
- @flac2mp3.stubs(:get_flacdata).returns(@flacdata)
519
- @flac2mp3.stubs(:set_mp3data)
539
+ @flacdata = mock('flac data')
540
+ @flac2mp3.stub!(:get_flacdata).and_return(@flacdata)
541
+ @flac2mp3.stub!(:set_mp3data)
520
542
  end
521
543
 
522
544
  it 'should accept a filename and an output filename' do
523
- lambda { @flac2mp3.convert_metadata(@filename, @out_filename) }.should_not raise_error(ArgumentError)
545
+ lambda { @flac2mp3.convert_metadata(@filename, @out_filename) }.should.not.raise(ArgumentError)
524
546
  end
525
547
 
526
548
  it 'should require an output filename' do
527
- lambda { @flac2mp3.convert_metadata(@filename) }.should raise_error(ArgumentError)
549
+ lambda { @flac2mp3.convert_metadata(@filename) }.should.raise(ArgumentError)
528
550
  end
529
551
 
530
552
  it 'should require a filename' do
531
- lambda { @flac2mp3.convert_metadata }.should raise_error(ArgumentError)
553
+ lambda { @flac2mp3.convert_metadata }.should.raise(ArgumentError)
532
554
  end
533
555
 
534
556
  it 'should get the flac metadata' do
535
- @flac2mp3.expects(:get_flacdata).with(@filename)
557
+ @flac2mp3.should.receive(:get_flacdata).with(@filename)
536
558
  @flac2mp3.convert_metadata(@filename, @out_filename)
537
559
  end
538
560
 
539
561
  it 'should set the mp3 metadata with the flac metadata' do
540
- @flac2mp3.expects(:set_mp3data).with(@out_filename, @flacdata)
562
+ @flac2mp3.should.receive(:set_mp3data).with(@out_filename, @flacdata)
541
563
  @flac2mp3.convert_metadata(@filename, @out_filename)
542
564
  end
543
565
  end
544
566
 
545
567
  it 'should get flac metadata' do
546
- @flac2mp3.should respond_to(:get_flacdata)
568
+ @flac2mp3.should.respond_to(:get_flacdata)
547
569
  end
548
570
 
549
571
  describe 'when getting flac metadata' do
550
- before :each do
572
+ before do
551
573
  @filename = 'test.flac'
552
574
  @tags = {}
553
- @flacinfo = stub('flacinfo', :tags => @tags)
554
- FlacInfo.stubs(:new).returns(@flacinfo)
575
+ @flacinfo = mock('flac info', :tags => @tags)
576
+ FlacInfo.stub!(:new).and_return(@flacinfo)
555
577
  end
556
578
 
557
579
  it 'should accept a filename' do
558
- lambda { @flac2mp3.get_flacdata(@filename) }.should_not raise_error(ArgumentError)
580
+ lambda { @flac2mp3.get_flacdata(@filename) }.should.not.raise(ArgumentError)
559
581
  end
560
582
 
561
583
  it 'should require a filename' do
562
- lambda { @flac2mp3.get_flacdata }.should raise_error(ArgumentError)
584
+ lambda { @flac2mp3.get_flacdata }.should.raise(ArgumentError)
563
585
  end
564
586
 
565
587
  it 'should create a FlacInfo object' do
566
- FlacInfo.expects(:new).with(@filename).returns(@flacinfo)
588
+ FlacInfo.should.receive(:new).with(@filename).and_return(@flacinfo)
567
589
  @flac2mp3.get_flacdata(@filename)
568
590
  end
569
591
 
570
592
  it 'should use the FlacInfo object tags' do
571
- @flacinfo.expects(:tags).returns(@tags)
593
+ @flacinfo.should.receive(:tags).and_return(@tags)
572
594
  @flac2mp3.get_flacdata(@filename)
573
595
  end
574
596
 
@@ -593,9 +615,9 @@ describe Flac2mp3 do
593
615
  data[:blah].should == 'boo'
594
616
  data[:comment].should == 'hey'
595
617
 
596
- data.should_not have_key('artist')
597
- data.should_not have_key('blah')
598
- data.should_not have_key('comment')
618
+ data.should.not.include('artist')
619
+ data.should.not.include('blah')
620
+ data.should.not.include('comment')
599
621
  end
600
622
 
601
623
  it 'should convert tags to lowercase' do
@@ -608,9 +630,9 @@ describe Flac2mp3 do
608
630
  data[:blah].should == 'boo'
609
631
  data[:comment].should == 'hey'
610
632
 
611
- data.should_not have_key('Artist')
612
- data.should_not have_key(:BLAH)
613
- data.should_not have_key('cOmMeNt')
633
+ data.should.not.include('Artist')
634
+ data.should.not.include(:BLAH)
635
+ data.should.not.include('cOmMeNt')
614
636
  end
615
637
 
616
638
  it 'should convert values consisting only of digits to actual numbers' do
@@ -654,44 +676,87 @@ describe Flac2mp3 do
654
676
  data = @flac2mp3.get_flacdata(@filename)
655
677
  data[:description].should == '1938'
656
678
  end
679
+
680
+ # iTunes wants ISO-8859-1, and I want my MP3s to display well in iTunes
681
+ it 'should convert UTF-8 titles to ISO-8859-1' do
682
+ @tags[:title] = "L\303\251gende"
683
+
684
+ data = @flac2mp3.get_flacdata(@filename)
685
+ data[:title].should == "L\351gende"
686
+ end
687
+
688
+ it 'should convert UTF-8 titles to ISO-8859-1 even if the title key is not a simple downcased symbol' do
689
+ @tags['TITLE'] = "L\303\251gende"
690
+
691
+ data = @flac2mp3.get_flacdata(@filename)
692
+ data[:title].should == "L\351gende"
693
+ end
694
+
695
+ it 'should convert UTF-8 artist names to ISO-8859-1' do
696
+ @tags[:artist] = "St\303\251phane Grappelli"
697
+
698
+ data = @flac2mp3.get_flacdata(@filename)
699
+ data[:artist].should == "St\351phane Grappelli"
700
+ end
701
+
702
+ it 'should convert UTF-8 artist names to ISO-8859-1 even if the artist key is not a simple downcased symbol' do
703
+ @tags['ARTIST'] = "St\303\251phane Grappelli"
704
+
705
+ data = @flac2mp3.get_flacdata(@filename)
706
+ data[:artist].should == "St\351phane Grappelli"
707
+ end
708
+
709
+ it 'should convert UTF-8 album titles to ISO-8859-1' do
710
+ @tags[:album] = "Still on Top \342\200\224 The Greatest Hits"
711
+
712
+ data = @flac2mp3.get_flacdata(@filename)
713
+ data[:album].should == "Still on Top - The Greatest Hits" # not a strict conversion, but a transliteration
714
+ end
715
+
716
+ it 'should convert UTF-8 album titles to ISO-8859-1 even if the album key is not a simple downcased symbol' do
717
+ @tags['ALBUM'] = "Still on Top \342\200\224 The Greatest Hits"
718
+
719
+ data = @flac2mp3.get_flacdata(@filename)
720
+ data[:album].should == "Still on Top - The Greatest Hits" # not a strict conversion, but a transliteration
721
+ end
657
722
  end
658
723
 
659
724
  it 'should set mp3 metadata' do
660
- @flac2mp3.should respond_to(:set_mp3data)
725
+ @flac2mp3.should.respond_to(:set_mp3data)
661
726
  end
662
727
 
663
728
  describe 'when setting mp3 metadata' do
664
- before :each do
729
+ before do
665
730
  @filename = 'test.mp3'
666
731
  @tags = {}
667
- @mp3tags = stub('mp3info tags')
668
- @mp3tags2 = stub('mp3info tags 2')
669
- @mp3info = stub('mp3info obj', :tag => @mp3tags, :tag2 => @mp3tags2)
670
- Mp3Info.stubs(:open).yields(@mp3info)
732
+ @mp3tags = mock('mp3 tags')
733
+ @mp3tags2 = mock('mp3 tags 2')
734
+ @mp3info = mock('mp3 info', :tag => @mp3tags, :tag2 => @mp3tags2)
735
+ Mp3Info.stub!(:open).and_yield(@mp3info)
671
736
  end
672
737
 
673
738
  it 'should accept a filename and tag data' do
674
- lambda { @flac2mp3.set_mp3data(@filename, 'tag data') }.should_not raise_error(ArgumentError)
739
+ lambda { @flac2mp3.set_mp3data(@filename, {}) }.should.not.raise(ArgumentError)
675
740
  end
676
741
 
677
742
  it 'should require tag data' do
678
- lambda { @flac2mp3.set_mp3data(@filename) }.should raise_error(ArgumentError)
743
+ lambda { @flac2mp3.set_mp3data(@filename) }.should.raise(ArgumentError)
679
744
  end
680
745
 
681
746
  it 'should require a filename' do
682
- lambda { @flac2mp3.set_mp3data }.should raise_error(ArgumentError)
747
+ lambda { @flac2mp3.set_mp3data }.should.raise(ArgumentError)
683
748
  end
684
749
 
685
750
  it 'should accept a hash of tag data' do
686
- lambda { @flac2mp3.set_mp3data(@filename, 'tag data') }.should raise_error(TypeError)
751
+ lambda { @flac2mp3.set_mp3data(@filename, 'tag data') }.should.raise(TypeError)
687
752
  end
688
753
 
689
754
  it 'should require a hash of tag data' do
690
- lambda { @flac2mp3.set_mp3data(@filename, {}) }.should_not raise_error(TypeError)
755
+ lambda { @flac2mp3.set_mp3data(@filename, {}) }.should.not.raise(TypeError)
691
756
  end
692
757
 
693
758
  it 'should use an Mp3Info object' do
694
- Mp3Info.expects(:open).with(@filename)
759
+ Mp3Info.should.receive(:open).with(@filename)
695
760
  @flac2mp3.set_mp3data(@filename, @tags)
696
761
  end
697
762
 
@@ -700,9 +765,9 @@ describe Flac2mp3 do
700
765
  @tags[:artist] = 'boo'
701
766
  @tags[:genre] = 'bang'
702
767
 
703
- @mp3tags.expects(:album=).with(@tags[:album])
704
- @mp3tags.expects(:artist=).with(@tags[:artist])
705
- @mp3tags.expects(:genre_s=).with(@tags[:genre])
768
+ @mp3tags.should.receive(:album=).with(@tags[:album])
769
+ @mp3tags.should.receive(:artist=).with(@tags[:artist])
770
+ @mp3tags.should.receive(:genre_s=).with(@tags[:genre])
706
771
 
707
772
  @flac2mp3.set_mp3data(@filename, @tags)
708
773
  end
@@ -712,12 +777,12 @@ describe Flac2mp3 do
712
777
  @tags[:artist] = 'boo'
713
778
  @tags[:genre] = 'bang'
714
779
 
715
- @mp3tags.stubs(:album=)
716
- @mp3tags.stubs(:artist=)
717
- @mp3tags.stubs(:genre_s=)
780
+ @mp3tags.stub!(:album=)
781
+ @mp3tags.stub!(:artist=)
782
+ @mp3tags.stub!(:genre_s=)
718
783
 
719
- @mp3tags.expects(:comments=).never
720
- @mp3tags.expects(:year=).never
784
+ @mp3tags.should.receive(:comments=).never
785
+ @mp3tags.should.receive(:year=).never
721
786
 
722
787
  @flac2mp3.set_mp3data(@filename, @tags)
723
788
  end
@@ -726,8 +791,8 @@ describe Flac2mp3 do
726
791
  @tags[:blah] = 'blah'
727
792
  @tags[:bang] = 'bang'
728
793
 
729
- @mp3tags.expects(:blah=).never
730
- @mp3tags.expects(:bang=).never
794
+ @mp3tags.should.receive(:blah=).never
795
+ @mp3tags.should.receive(:bang=).never
731
796
 
732
797
  @flac2mp3.set_mp3data(@filename, @tags)
733
798
  end
@@ -735,7 +800,7 @@ describe Flac2mp3 do
735
800
  it 'should use tag2 for bpm' do
736
801
  @tags[:bpm] = '5'
737
802
 
738
- @mp3tags2.expects(:TBPM=).with(@tags[:bpm])
803
+ @mp3tags2.should.receive(:TBPM=).with(@tags[:bpm])
739
804
 
740
805
  @flac2mp3.set_mp3data(@filename, @tags)
741
806
  end
@@ -743,7 +808,7 @@ describe Flac2mp3 do
743
808
  it 'should use tag2 for composer' do
744
809
  @tags[:composer] = 'Il Maestro'
745
810
 
746
- @mp3tags2.expects(:TCOM=).with(@tags[:composer])
811
+ @mp3tags2.should.receive(:TCOM=).with(@tags[:composer])
747
812
 
748
813
  @flac2mp3.set_mp3data(@filename, @tags)
749
814
  end
@@ -751,7 +816,7 @@ describe Flac2mp3 do
751
816
  it 'should use tag2 for compilation' do
752
817
  @tags[:compilation] = '1'
753
818
 
754
- @mp3tags2.expects(:TCMP=).with(@tags[:compilation])
819
+ @mp3tags2.should.receive(:TCMP=).with(@tags[:compilation])
755
820
 
756
821
  @flac2mp3.set_mp3data(@filename, @tags)
757
822
  end
@@ -759,7 +824,7 @@ describe Flac2mp3 do
759
824
  it "should use tag2 for 'tag' ('grouping')" do
760
825
  @tags[:tag] = 'one, two, three, oclock'
761
826
 
762
- @mp3tags2.expects(:TIT1=).with(@tags[:tag])
827
+ @mp3tags2.should.receive(:TIT1=).with(@tags[:tag])
763
828
 
764
829
  @flac2mp3.set_mp3data(@filename, @tags)
765
830
  end
@@ -768,7 +833,7 @@ describe Flac2mp3 do
768
833
  @tags[:tracknumber] = 4
769
834
  @tags[:tracktotal] = 15
770
835
 
771
- @mp3tags2.expects(:TRCK=).with('4/15')
836
+ @mp3tags2.should.receive(:TRCK=).with('4/15')
772
837
 
773
838
  @flac2mp3.set_mp3data(@filename, @tags)
774
839
  end
@@ -777,7 +842,7 @@ describe Flac2mp3 do
777
842
  @tags[:discnumber] = 1
778
843
  @tags[:disctotal] = 2
779
844
 
780
- @mp3tags2.expects(:TPOS=).with('1/2')
845
+ @mp3tags2.should.receive(:TPOS=).with('1/2')
781
846
 
782
847
  @flac2mp3.set_mp3data(@filename, @tags)
783
848
  end
@@ -785,83 +850,83 @@ describe Flac2mp3 do
785
850
 
786
851
  describe 'as a class' do
787
852
  it 'should convert' do
788
- Flac2mp3.should respond_to(:convert)
853
+ Flac2mp3.should.respond_to(:convert)
789
854
  end
790
855
 
791
856
  describe 'when converting' do
792
- before :each do
857
+ before do
793
858
  @filename = 'test.flac'
794
859
  @options = { :silent => true, :delete => false, :fish => :flat }
795
- @flac2mp3 = stub('flac2mp3 object', :convert => nil)
796
- Flac2mp3.stubs(:new).returns(@flac2mp3)
860
+ @flac2mp3 = mock('flac2mp3', :convert => nil)
861
+ Flac2mp3.stub!(:new).and_return(@flac2mp3)
797
862
  end
798
863
 
799
864
  it 'should accept a filename and a hash of options' do
800
- lambda { Flac2mp3.convert(@filename, @options) }.should_not raise_error(ArgumentError)
865
+ lambda { Flac2mp3.convert(@filename, @options) }.should.not.raise(ArgumentError)
801
866
  end
802
867
 
803
868
  it 'should not require options' do
804
- lambda { Flac2mp3.convert(@filename) }.should_not raise_error(ArgumentError)
869
+ lambda { Flac2mp3.convert(@filename) }.should.not.raise(ArgumentError)
805
870
  end
806
871
 
807
872
  it 'should require a filename' do
808
- lambda { Flac2mp3.convert }.should raise_error(ArgumentError)
873
+ lambda { Flac2mp3.convert }.should.raise(ArgumentError)
809
874
  end
810
875
 
811
876
  it 'should instantiate a new Flac2mp3 object' do
812
- Flac2mp3.expects(:new).returns(@flac2mp3)
877
+ Flac2mp3.should.receive(:new).and_return(@flac2mp3)
813
878
  Flac2mp3.convert(@filename)
814
879
  end
815
880
 
816
881
  it 'should pass the options when instantiating the Flac2mp3 object' do
817
- Flac2mp3.expects(:new).with(@options).returns(@flac2mp3)
882
+ Flac2mp3.should.receive(:new).with(@options).and_return(@flac2mp3)
818
883
  Flac2mp3.convert(@filename, @options)
819
884
  end
820
885
 
821
886
  it 'should use the Flac2mp3 object to convert the given file' do
822
- @flac2mp3.expects(:convert).with(@filename)
887
+ @flac2mp3.should.receive(:convert).with(@filename)
823
888
  Flac2mp3.convert(@filename)
824
889
  end
825
890
  end
826
891
 
827
892
  it 'should convert metadata' do
828
- Flac2mp3.should respond_to(:convert_metadata)
893
+ Flac2mp3.should.respond_to(:convert_metadata)
829
894
  end
830
895
 
831
896
  describe 'when converting metadata' do
832
- before :each do
897
+ before do
833
898
  @infile = 'test.flac'
834
899
  @outfile = 'some.mp3'
835
- @flac2mp3 = stub('flac2mp3 object', :convert_metadata => nil)
836
- Flac2mp3.stubs(:new).returns(@flac2mp3)
900
+ @flac2mp3 = mock('flac2mp3', :convert_metadata => nil)
901
+ Flac2mp3.stub!(:new).and_return(@flac2mp3)
837
902
  end
838
903
 
839
904
  it 'should accept two filenames' do
840
- lambda { Flac2mp3.convert_metadata(@infile, @outfile) }.should_not raise_error(ArgumentError)
905
+ lambda { Flac2mp3.convert_metadata(@infile, @outfile) }.should.not.raise(ArgumentError)
841
906
  end
842
907
 
843
908
  it 'should require two filenames' do
844
- lambda { Flac2mp3.convert_metadata(@infile) }.should raise_error(ArgumentError)
909
+ lambda { Flac2mp3.convert_metadata(@infile) }.should.raise(ArgumentError)
845
910
  end
846
911
 
847
912
  it 'should instantiate a new Flac2mp3 object' do
848
- Flac2mp3.expects(:new).returns(@flac2mp3)
913
+ Flac2mp3.should.receive(:new).and_return(@flac2mp3)
849
914
  Flac2mp3.convert_metadata(@infile, @outfile)
850
915
  end
851
916
 
852
917
  it 'should use the Flac2mp3 object to convert the metadata between the given files' do
853
- @flac2mp3.expects(:convert_metadata).with(@infile, @outfile)
918
+ @flac2mp3.should.receive(:convert_metadata).with(@infile, @outfile)
854
919
  Flac2mp3.convert_metadata(@infile, @outfile)
855
920
  end
856
921
  end
857
922
 
858
923
  it 'should provide a tag mapping' do
859
- Flac2mp3.should respond_to(:tag_mapping)
924
+ Flac2mp3.should.respond_to(:tag_mapping)
860
925
  end
861
926
 
862
927
  describe 'providing a tag mapping' do
863
928
  it 'should return a hash' do
864
- Flac2mp3.tag_mapping.should be_kind_of(Hash)
929
+ Flac2mp3.tag_mapping.should.be.kind_of(Hash)
865
930
  end
866
931
 
867
932
  it "should map 'album' to 'album'" do