lame 0.0.3 → 0.0.5

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +47 -0
  3. data/.travis.yml +3 -4
  4. data/README.md +51 -19
  5. data/docs/lame-3.101.h +1357 -0
  6. data/lame.gemspec +2 -1
  7. data/lib/lame/buffer.rb +1 -1
  8. data/lib/lame/encoder.rb +10 -11
  9. data/lib/lame/encoding/interleaved_int_buffer_encoder.rb +15 -0
  10. data/lib/lame/encoding/long_buffer_encoder.rb +1 -1
  11. data/lib/lame/encoding/stereo_buffer_encoder.rb +1 -0
  12. data/lib/lame/ffi/functions.rb +99 -38
  13. data/lib/lame/ffi.rb +2 -0
  14. data/lib/lame/version.rb +1 -1
  15. data/lib/lame.rb +2 -0
  16. data/spec/buffer_spec.rb +8 -8
  17. data/spec/configuration_spec.rb +76 -76
  18. data/spec/decoder_spec.rb +34 -34
  19. data/spec/decoding/decoded_frame_spec.rb +7 -7
  20. data/spec/decoding/id3_tag_parser_spec.rb +3 -3
  21. data/spec/decoding/mp3_data_header_parser_spec.rb +21 -21
  22. data/spec/decoding/mpeg_audio_frame_finder_spec.rb +15 -15
  23. data/spec/decoding/mpeg_audio_frame_matcher_spec.rb +2 -2
  24. data/spec/decoding/single_frame_decoder_spec.rb +36 -35
  25. data/spec/decoding/stream_decoder_spec.rb +10 -10
  26. data/spec/delegation_spec.rb +37 -37
  27. data/spec/encoder_spec.rb +100 -100
  28. data/spec/encoding/flusher_spec.rb +16 -16
  29. data/spec/encoding/id3_spec.rb +38 -38
  30. data/spec/encoding/interleaved_buffer_encoder_spec.rb +32 -25
  31. data/spec/encoding/stereo_buffer_encoder_spec.rb +34 -33
  32. data/spec/encoding/vbr_info_spec.rb +16 -16
  33. data/spec/ffi/decode_flags_spec.rb +3 -2
  34. data/spec/ffi/encoding_spec.rb +22 -22
  35. data/spec/ffi/global_flags_spec.rb +166 -160
  36. data/spec/ffi/id3tag_spec.rb +26 -26
  37. data/spec/ffi/mp3_data_spec.rb +3 -3
  38. data/spec/integration/encoding_spec.rb +75 -3
  39. data/spec/integration/id3_tags_spec.rb +18 -18
  40. data/spec/lib/custom_matchers.rb +4 -4
  41. data/spec/lib/wave_file_generator.rb +9 -9
  42. data/spec/spec_helper.rb +14 -10
  43. metadata +58 -67
data/spec/encoder_spec.rb CHANGED
@@ -8,7 +8,7 @@ module LAME
8
8
  context "initialization" do
9
9
 
10
10
  it "initializes GlobalFlags" do
11
- FFI::GlobalFlags.should_receive(:new)
11
+ expect(FFI::GlobalFlags).to receive(:new)
12
12
  Encoder.new
13
13
  end
14
14
 
@@ -16,14 +16,14 @@ module LAME
16
16
 
17
17
  context "configuration" do
18
18
 
19
- let(:configuration) { stub(Configuration).as_null_object }
19
+ let(:configuration) { double(Configuration).as_null_object }
20
20
 
21
21
  before do
22
- Configuration.stub(:new).and_return(configuration)
22
+ allow(Configuration).to receive(:new).and_return(configuration)
23
23
  end
24
24
 
25
25
  it "initializes a Configuration object" do
26
- Configuration.should_receive(:new).with(kind_of(GlobalFlags))
26
+ expect(Configuration).to receive(:new).with(kind_of(GlobalFlags))
27
27
  encoder.configure { }
28
28
  end
29
29
 
@@ -35,18 +35,18 @@ module LAME
35
35
 
36
36
  it "assigns the Configuration object" do
37
37
  encoder.configure { }
38
- encoder.configuration.should eql configuration
38
+ expect(encoder.configuration).to eql configuration
39
39
  end
40
40
 
41
41
  it "applies the configuration" do
42
- configuration.stub(:applied?).and_return(false)
43
- configuration.should_receive(:apply!)
42
+ allow(configuration).to receive(:applied?).and_return(false)
43
+ expect(configuration).to receive(:apply!)
44
44
  encoder.configure { }
45
45
  end
46
46
 
47
47
  it "gets the framesize" do
48
- configuration.should_receive(:framesize).and_return(1234)
49
- encoder.framesize.should eql 1234
48
+ expect(configuration).to receive(:framesize).and_return(1234)
49
+ expect(encoder.framesize).to eql 1234
50
50
  end
51
51
  end
52
52
 
@@ -57,54 +57,54 @@ module LAME
57
57
  let(:samples) { [0,0] }
58
58
 
59
59
  let(:global_flags) { subject.global_flags }
60
- let(:configuration) { stub(Configuration, :framesize => 100) }
60
+ let(:configuration) { double(Configuration, :framesize => 100) }
61
61
 
62
62
  before do
63
- Configuration.stub(:new).and_return(configuration)
64
- configuration.stub(:applied?).and_return(true)
63
+ allow(Configuration).to receive(:new).and_return(configuration)
64
+ allow(configuration).to receive(:applied?).and_return(true)
65
65
  end
66
66
 
67
67
  describe "#encode_short" do
68
68
 
69
69
  before do
70
- Encoding::ShortBufferEncoder.stub(:new).and_return(stub.as_null_object)
70
+ allow(Encoding::ShortBufferEncoder).to receive(:new).and_return(double.as_null_object)
71
71
  end
72
72
 
73
73
  it "applies the configuration if not done already" do
74
- configuration.stub(:applied?).and_return(false)
75
- configuration.should_receive(:apply!)
74
+ allow(configuration).to receive(:applied?).and_return(false)
75
+ expect(configuration).to receive(:apply!)
76
76
  encoder.encode_short(left, right) { }
77
77
  end
78
78
 
79
79
  it "does not apply the configuration if already applied" do
80
- configuration.stub(:applied?).and_return(true)
81
- configuration.should_not_receive(:apply!)
80
+ allow(configuration).to receive(:applied?).and_return(true)
81
+ expect(configuration).to_not receive(:apply!)
82
82
  encoder.encode_short(left, right) { }
83
83
  end
84
84
 
85
85
  context "delegation" do
86
- let(:short_encoder) { stub.as_null_object }
86
+ let(:short_encoder) { double.as_null_object }
87
87
 
88
88
  before do
89
- Encoding::ShortBufferEncoder.stub(:new).and_return(short_encoder)
89
+ allow(Encoding::ShortBufferEncoder).to receive(:new).and_return(short_encoder)
90
90
  end
91
91
 
92
92
  it "create a short encoder with configuration" do
93
- Encoding::ShortBufferEncoder.should_receive(:new).with(configuration)
93
+ expect(Encoding::ShortBufferEncoder).to receive(:new).with(configuration)
94
94
 
95
95
  encoder.encode_short(left, right) { }
96
96
  end
97
97
 
98
98
  it "delegates encoding to the short encoder" do
99
- left.stub(:length => 100) # exactly framesize
100
- short_encoder.should_receive(:encode_frame).with(left, right)
99
+ allow(left).to receive_messages(:length => 100) # exactly framesize
100
+ expect(short_encoder).to receive(:encode_frame).with(left, right)
101
101
 
102
102
  encoder.encode_short(left, right) { }
103
103
  end
104
104
 
105
105
  it "yields the encoder results" do
106
- mp3_data = stub
107
- short_encoder.stub(:encode_frame).and_return(mp3_data)
106
+ mp3_data = double("mp3_data")
107
+ allow(short_encoder).to receive(:encode_frame).and_return(mp3_data)
108
108
 
109
109
  expect { |block|
110
110
  encoder.encode_short(left, right, &block)
@@ -114,26 +114,26 @@ module LAME
114
114
  it "delegates multiple times for large input" do
115
115
  right = left = [0]*150 # larger than framesize
116
116
 
117
- short_encoder.should_receive(:encode_frame) do |left_frame, right_frame|
118
- left_frame.length.should eql 100
119
- right_frame.length.should eql 100
117
+ expect(short_encoder).to receive(:encode_frame) do |left_frame, right_frame|
118
+ expect(left_frame.length).to eql 100
119
+ expect(right_frame.length).to eql 100
120
120
  end
121
121
 
122
- short_encoder.should_receive(:encode_frame) do |left_frame, right_frame|
123
- left_frame.length.should eql 50
124
- right_frame.length.should eql 50
122
+ expect(short_encoder).to receive(:encode_frame) do |left_frame, right_frame|
123
+ expect(left_frame.length).to eql 50
124
+ expect(right_frame.length).to eql 50
125
125
  end
126
126
 
127
127
  encoder.encode_short(left, right) { }
128
128
  end
129
129
 
130
130
  it "yields multiple times for large input" do
131
- mp3_data1 = stub("frame1")
132
- mp3_data2 = stub("frame2")
131
+ mp3_data1 = double("frame1")
132
+ mp3_data2 = double("frame2")
133
133
 
134
134
  left = [0]*150 # larger than framesize
135
135
 
136
- short_encoder.stub(:encode_frame).and_return(mp3_data1, mp3_data2)
136
+ allow(short_encoder).to receive(:encode_frame).and_return(mp3_data1, mp3_data2)
137
137
 
138
138
  expect { |block|
139
139
  encoder.encode_short(left, right, &block)
@@ -144,8 +144,8 @@ module LAME
144
144
 
145
145
  describe "#encode_float" do
146
146
  it "create a float encoder" do
147
- Encoding::FloatBufferEncoder.stub(:new).and_return(stub.as_null_object)
148
- Encoding::FloatBufferEncoder.should_receive(:new).with(configuration)
147
+ allow(Encoding::FloatBufferEncoder).to receive(:new).and_return(double.as_null_object)
148
+ expect(Encoding::FloatBufferEncoder).to receive(:new).with(configuration)
149
149
 
150
150
  encoder.encode_float(left, right) { }
151
151
  end
@@ -153,8 +153,8 @@ module LAME
153
153
 
154
154
  describe "#encode_long" do
155
155
  it "create a long encoder" do
156
- Encoding::LongBufferEncoder.stub(:new).and_return(stub.as_null_object)
157
- Encoding::LongBufferEncoder.should_receive(:new).with(configuration)
156
+ allow(Encoding::LongBufferEncoder).to receive(:new).and_return(double.as_null_object)
157
+ expect(Encoding::LongBufferEncoder).to receive(:new).with(configuration)
158
158
 
159
159
  encoder.encode_long(left, right) { }
160
160
  end
@@ -163,44 +163,44 @@ module LAME
163
163
  describe "#encode_interleaved_short" do
164
164
 
165
165
  before do
166
- Encoding::InterleavedShortBufferEncoder.stub(:new).and_return(stub.as_null_object)
166
+ allow(Encoding::InterleavedShortBufferEncoder).to receive(:new).and_return(double.as_null_object)
167
167
  end
168
168
 
169
169
  it "applies the configuration if not done already" do
170
- configuration.stub(:applied?).and_return(false)
171
- configuration.should_receive(:apply!)
170
+ allow(configuration).to receive(:applied?).and_return(false)
171
+ expect(configuration).to receive(:apply!)
172
172
  encoder.encode_interleaved_short(samples) { }
173
173
  end
174
174
 
175
175
  it "does not apply the configuration if already applied" do
176
- configuration.stub(:applied?).and_return(true)
177
- configuration.should_not_receive(:apply!)
176
+ allow(configuration).to receive(:applied?).and_return(true)
177
+ expect(configuration).to_not receive(:apply!)
178
178
  encoder.encode_interleaved_short(samples) { }
179
179
  end
180
180
 
181
181
  context "delegation" do
182
- let(:interleaved_short_encoder) { stub.as_null_object }
182
+ let(:interleaved_short_encoder) { double.as_null_object }
183
183
 
184
184
  before do
185
- Encoding::InterleavedShortBufferEncoder.stub(:new).and_return(interleaved_short_encoder)
185
+ allow(Encoding::InterleavedShortBufferEncoder).to receive(:new).and_return(interleaved_short_encoder)
186
186
  end
187
187
 
188
188
  it "create a short encoder with configuration" do
189
- Encoding::InterleavedShortBufferEncoder.should_receive(:new).with(configuration)
189
+ expect(Encoding::InterleavedShortBufferEncoder).to receive(:new).with(configuration)
190
190
 
191
191
  encoder.encode_interleaved_short(samples) { }
192
192
  end
193
193
 
194
194
  it "delegates encoding to the short encoder" do
195
- samples.stub(:length => 200) # exactly framesize
196
- interleaved_short_encoder.should_receive(:encode_frame).with(samples)
195
+ allow(samples).to receive_messages(:length => 200) # exactly framesize
196
+ expect(interleaved_short_encoder).to receive(:encode_frame).with(samples)
197
197
 
198
198
  encoder.encode_interleaved_short(samples) { }
199
199
  end
200
200
 
201
201
  it "yields the encoder results" do
202
- mp3_data = stub
203
- interleaved_short_encoder.stub(:encode_frame).and_return(mp3_data)
202
+ mp3_data = double("mp3_data")
203
+ allow(interleaved_short_encoder).to receive(:encode_frame).and_return(mp3_data)
204
204
 
205
205
  expect { |block|
206
206
  encoder.encode_interleaved_short(samples, &block)
@@ -210,24 +210,24 @@ module LAME
210
210
  it "delegates multiple times for large input" do
211
211
  samples = [0]*300 # larger than framesize
212
212
 
213
- interleaved_short_encoder.should_receive(:encode_frame) do |samples|
214
- samples.length.should eql 200
213
+ expect(interleaved_short_encoder).to receive(:encode_frame) do |samples|
214
+ expect(samples.length).to eql 200
215
215
  end
216
216
 
217
- interleaved_short_encoder.should_receive(:encode_frame) do |samples|
218
- samples.length.should eql 100
217
+ expect(interleaved_short_encoder).to receive(:encode_frame) do |samples|
218
+ expect(samples.length).to eql 100
219
219
  end
220
220
 
221
221
  encoder.encode_interleaved_short(samples) { }
222
222
  end
223
223
 
224
224
  it "yields multiple times for large input" do
225
- mp3_data1 = stub("frame1")
226
- mp3_data2 = stub("frame2")
225
+ mp3_data1 = double("frame1")
226
+ mp3_data2 = double("frame2")
227
227
 
228
228
  samples = [0]*300 # larger than framesize
229
229
 
230
- interleaved_short_encoder.stub(:encode_frame).and_return(mp3_data1, mp3_data2)
230
+ allow(interleaved_short_encoder).to receive(:encode_frame).and_return(mp3_data1, mp3_data2)
231
231
 
232
232
  expect { |block|
233
233
  encoder.encode_interleaved_short(samples, &block)
@@ -238,8 +238,8 @@ module LAME
238
238
 
239
239
  describe "#encode_interleaved_float" do
240
240
  it "create a float encoder" do
241
- Encoding::InterleavedFloatBufferEncoder.stub(:new).and_return(stub.as_null_object)
242
- Encoding::InterleavedFloatBufferEncoder.should_receive(:new).with(configuration)
241
+ allow(Encoding::InterleavedFloatBufferEncoder).to receive(:new).and_return(double.as_null_object)
242
+ expect(Encoding::InterleavedFloatBufferEncoder).to receive(:new).with(configuration)
243
243
 
244
244
  encoder.encode_interleaved_float(samples) { }
245
245
  end
@@ -250,28 +250,28 @@ module LAME
250
250
  context "flushing" do
251
251
 
252
252
  let(:global_flags) { subject.global_flags }
253
- let(:configuration) { stub(Configuration) }
254
- let(:flusher) { stub(Encoding::Flusher).as_null_object }
253
+ let(:configuration) { double(Configuration) }
254
+ let(:flusher) { double(Encoding::Flusher).as_null_object }
255
255
 
256
256
  before do
257
- Configuration.stub(:new).and_return(configuration)
258
- configuration.stub(:applied?).and_return(true)
259
- Encoding::Flusher.stub(:new).and_return(flusher)
257
+ allow(Configuration).to receive(:new).and_return(configuration)
258
+ allow(configuration).to receive(:applied?).and_return(true)
259
+ allow(Encoding::Flusher).to receive(:new).and_return(flusher)
260
260
  end
261
261
 
262
262
  it "creates a flusher" do
263
- Encoding::Flusher.should_receive(:new).with(configuration)
263
+ expect(Encoding::Flusher).to receive(:new).with(configuration)
264
264
  encoder.flush { }
265
265
  end
266
266
 
267
267
  it "flushes the final frame" do
268
- flusher.should_receive(:flush)
268
+ expect(flusher).to receive(:flush)
269
269
  encoder.flush { }
270
270
  end
271
271
 
272
272
  it "yields the flushed mp3 data" do
273
- mp3_data = stub
274
- flusher.stub(:flush).and_return(mp3_data)
273
+ mp3_data = double("mp3_data")
274
+ allow(flusher).to receive(:flush).and_return(mp3_data)
275
275
 
276
276
  expect { |block|
277
277
  encoder.flush(&block)
@@ -279,9 +279,9 @@ module LAME
279
279
  end
280
280
 
281
281
  it "returns the flushed data if no block was given" do
282
- mp3_data = stub
283
- flusher.stub(:flush).and_return(mp3_data)
284
- encoder.flush.should eql mp3_data
282
+ mp3_data = double("mp3_data")
283
+ allow(flusher).to receive(:flush).and_return(mp3_data)
284
+ expect(encoder.flush).to eql mp3_data
285
285
  end
286
286
 
287
287
  end
@@ -289,28 +289,28 @@ module LAME
289
289
  context "lametag frame" do
290
290
 
291
291
  let(:global_flags) { subject.global_flags }
292
- let(:configuration) { stub(Configuration) }
293
- let(:vbr_info) { stub(Encoding::VBRInfo).as_null_object }
292
+ let(:configuration) { double(Configuration) }
293
+ let(:vbr_info) { double(Encoding::VBRInfo).as_null_object }
294
294
 
295
295
  before do
296
- Configuration.stub(:new).and_return(configuration)
297
- configuration.stub(:applied?).and_return(true)
298
- Encoding::VBRInfo.stub(:new).and_return(vbr_info)
296
+ allow(Configuration).to receive(:new).and_return(configuration)
297
+ allow(configuration).to receive(:applied?).and_return(true)
298
+ allow(Encoding::VBRInfo).to receive(:new).and_return(vbr_info)
299
299
  end
300
300
 
301
301
  it "creates vbr info" do
302
- Encoding::VBRInfo.should_receive(:new).with(configuration)
302
+ expect(Encoding::VBRInfo).to receive(:new).with(configuration)
303
303
  encoder.vbr_frame { }
304
304
  end
305
305
 
306
306
  it "creates the vbr frame" do
307
- vbr_info.should_receive(:frame)
307
+ expect(vbr_info).to receive(:frame)
308
308
  encoder.vbr_frame { }
309
309
  end
310
310
 
311
311
  it "yields the vbr frame" do
312
- mp3_data = stub
313
- vbr_info.stub(:frame).and_return(mp3_data)
312
+ mp3_data = double("mp3_data")
313
+ allow(vbr_info).to receive(:frame).and_return(mp3_data)
314
314
 
315
315
  expect { |block|
316
316
  encoder.vbr_frame(&block)
@@ -318,38 +318,38 @@ module LAME
318
318
  end
319
319
 
320
320
  it "returns the vbr frame if no block was given" do
321
- mp3_data = stub
322
- vbr_info.stub(:frame).and_return(mp3_data)
323
- encoder.vbr_frame.should eql mp3_data
321
+ mp3_data = double("mp3_data")
322
+ allow(vbr_info).to receive(:frame).and_return(mp3_data)
323
+ expect(encoder.vbr_frame).to eql mp3_data
324
324
  end
325
325
 
326
326
  end
327
327
 
328
328
  context "id3" do
329
329
  let(:global_flags) { subject.global_flags }
330
- let(:configuration) { stub(Configuration) }
331
- let(:id3) { stub(Encoding::Id3).as_null_object }
330
+ let(:configuration) { double(Configuration) }
331
+ let(:id3) { double(Encoding::Id3).as_null_object }
332
332
 
333
333
  before do
334
- Configuration.stub(:new).and_return(configuration)
335
- configuration.stub(:applied?).and_return(true)
336
- Encoding::Id3.stub(:new).and_return(id3)
334
+ allow(Configuration).to receive(:new).and_return(configuration)
335
+ allow(configuration).to receive(:applied?).and_return(true)
336
+ allow(Encoding::Id3).to receive(:new).and_return(id3)
337
337
  end
338
338
 
339
339
  it "creates vbr info" do
340
- Encoding::Id3.should_receive(:new).with(configuration)
340
+ expect(Encoding::Id3).to receive(:new).with(configuration)
341
341
  encoder.id3v1 { }
342
342
  end
343
343
 
344
344
  context "v1" do
345
345
  it "creates the id3v1 frame" do
346
- id3.should_receive(:v1)
346
+ expect(id3).to receive(:v1)
347
347
  encoder.id3v1 { }
348
348
  end
349
349
 
350
350
  it "yields the vbr frame" do
351
- mp3_data = stub
352
- id3.stub(:v1).and_return(mp3_data)
351
+ mp3_data = double("mp3_data")
352
+ allow(id3).to receive(:v1).and_return(mp3_data)
353
353
 
354
354
  expect { |block|
355
355
  encoder.id3v1(&block)
@@ -357,21 +357,21 @@ module LAME
357
357
  end
358
358
 
359
359
  it "returns the vbr frame if no block was given" do
360
- mp3_data = stub
361
- id3.stub(:v1).and_return(mp3_data)
362
- encoder.id3v1.should eql mp3_data
360
+ mp3_data = double("mp3_data")
361
+ allow(id3).to receive(:v1).and_return(mp3_data)
362
+ expect(encoder.id3v1).to eql mp3_data
363
363
  end
364
364
  end
365
365
 
366
366
  context "v2" do
367
367
  it "creates the id3v2 frame" do
368
- id3.should_receive(:v2)
368
+ expect(id3).to receive(:v2)
369
369
  encoder.id3v2 { }
370
370
  end
371
371
 
372
372
  it "yields the vbr frame" do
373
- mp3_data = stub
374
- id3.stub(:v2).and_return(mp3_data)
373
+ mp3_data = double("mp3_data")
374
+ allow(id3).to receive(:v2).and_return(mp3_data)
375
375
 
376
376
  expect { |block|
377
377
  encoder.id3v2(&block)
@@ -379,9 +379,9 @@ module LAME
379
379
  end
380
380
 
381
381
  it "returns the vbr frame if no block was given" do
382
- mp3_data = stub
383
- id3.stub(:v2).and_return(mp3_data)
384
- encoder.id3v2.should eql mp3_data
382
+ mp3_data = double("mp3_data")
383
+ allow(id3).to receive(:v2).and_return(mp3_data)
384
+ expect(encoder.id3v2).to eql mp3_data
385
385
  end
386
386
  end
387
387
  end
@@ -4,42 +4,42 @@ module LAME
4
4
  module Encoding
5
5
  describe Flusher do
6
6
 
7
- let(:global_flags) { stub }
8
- let(:configuration) { stub(Configuration, :global_flags => global_flags, :framesize => 1152, :output_buffer_size => 8640) }
7
+ let(:global_flags) { double("global_flags") }
8
+ let(:configuration) { double(Configuration, :global_flags => global_flags, :framesize => 1152, :output_buffer_size => 8640) }
9
9
 
10
10
  subject(:flusher) { Flusher.new(configuration) }
11
11
 
12
12
  it "creates output buffer" do
13
- LAME.stub(:lame_encode_flush).and_return(0)
13
+ allow(LAME).to receive(:lame_encode_flush).and_return(0)
14
14
 
15
- Buffer.should_receive(:create_empty).with(:uchar, 8640).and_return(stub.as_null_object)
15
+ expect(Buffer).to receive(:create_empty).with(:uchar, 8640).and_return(double.as_null_object)
16
16
 
17
17
  flusher.flush
18
18
  end
19
19
 
20
20
  it "flushes" do
21
- output_stub = stub("output", :get_bytes => [])
22
- Buffer.stub(:create_empty).with(:uchar, 8640).and_return(output_stub)
21
+ output_double = double("output", :get_bytes => [])
22
+ allow(Buffer).to receive(:create_empty).with(:uchar, 8640).and_return(output_double)
23
23
 
24
- LAME.should_receive(:lame_encode_flush) do |flags, buffer, buffer_size|
25
- flags.should eql global_flags
26
- buffer.should eql output_stub
27
- buffer_size.should eql 8640
24
+ expect(LAME).to receive(:lame_encode_flush) do |flags, buffer, buffer_size|
25
+ expect(flags).to eql global_flags
26
+ expect(buffer).to eql output_double
27
+ expect(buffer_size).to eql 8640
28
28
  end
29
29
 
30
30
  flusher.flush
31
31
  end
32
32
 
33
33
  it "returns the flushed data" do
34
- LAME.stub(:lame_encode_flush).and_return(512)
34
+ allow(LAME).to receive(:lame_encode_flush).and_return(512)
35
35
 
36
- mp3_data = stub
37
- output = stub
38
- output.stub(:get_bytes).with(0, 512).and_return(mp3_data)
36
+ mp3_data = double("mp3_data")
37
+ output = double("output")
38
+ allow(output).to receive(:get_bytes).with(0, 512).and_return(mp3_data)
39
39
 
40
- Buffer.stub(:create_empty).with(:uchar, 8640).and_return(output)
40
+ allow(Buffer).to receive(:create_empty).with(:uchar, 8640).and_return(output)
41
41
 
42
- flusher.flush.should eql mp3_data
42
+ expect(flusher.flush).to eql mp3_data
43
43
  end
44
44
 
45
45
  end
@@ -4,100 +4,100 @@ module LAME
4
4
  module Encoding
5
5
  describe Id3 do
6
6
 
7
- let(:global_flags) { stub }
8
- let(:configuration) { stub(Configuration, :global_flags => global_flags, :framesize => 1152, :output_buffer_size => 8640) }
7
+ let(:global_flags) { double }
8
+ let(:configuration) { double(Configuration, :global_flags => global_flags, :framesize => 1152, :output_buffer_size => 8640) }
9
9
 
10
10
  subject(:id3) { Id3.new(configuration) }
11
11
 
12
12
  describe "#v1" do
13
13
  it "creates empty and filled output buffer" do
14
- LAME.stub(:lame_get_id3v1_tag).and_return(1024, 1024)
14
+ allow(LAME).to receive(:lame_get_id3v1_tag).and_return(1024, 1024)
15
15
 
16
16
  # Determine size
17
- Buffer.should_receive(:create_empty).with(:uchar, 0).and_return(stub.as_null_object)
17
+ expect(Buffer).to receive(:create_empty).with(:uchar, 0).and_return(double.as_null_object)
18
18
 
19
19
  # Actual tag
20
- Buffer.should_receive(:create_empty).with(:uchar, 1024).and_return(stub.as_null_object)
20
+ expect(Buffer).to receive(:create_empty).with(:uchar, 1024).and_return(double.as_null_object)
21
21
 
22
22
  id3.v1
23
23
  end
24
24
 
25
25
  it "creates tag" do
26
26
  # Determine size
27
- LAME.should_receive(:lame_get_id3v1_tag) do |flags, buffer, buffer_size|
28
- flags.should eql global_flags
29
- buffer.size.should eql 0
30
- buffer_size.should eql 0
27
+ expect(LAME).to receive(:lame_get_id3v1_tag) do |flags, buffer, buffer_size|
28
+ expect(flags).to eql global_flags
29
+ expect(buffer.size).to eql 0
30
+ expect(buffer_size).to eql 0
31
31
  1024
32
32
  end
33
33
 
34
34
  # Get actual tag
35
- LAME.should_receive(:lame_get_id3v1_tag) do |flags, buffer, buffer_size|
36
- flags.should eql global_flags
37
- buffer.size.should eql 1024
38
- buffer_size.should eql 1024
35
+ expect(LAME).to receive(:lame_get_id3v1_tag) do |flags, buffer, buffer_size|
36
+ expect(flags).to eql global_flags
37
+ expect(buffer.size).to eql 1024
38
+ expect(buffer_size).to eql 1024
39
39
  end
40
40
 
41
41
  id3.v1
42
42
  end
43
43
 
44
44
  it "returns the id3 tag" do
45
- LAME.stub(:lame_get_id3v1_tag).and_return(512, 512)
45
+ allow(LAME).to receive(:lame_get_id3v1_tag).and_return(512, 512)
46
46
 
47
- mp3_data = stub
48
- output = stub
49
- output.stub(:get_bytes).with(0, 512).and_return(mp3_data)
47
+ mp3_data = double("mp3_data")
48
+ output = double("output")
49
+ allow(output).to receive(:get_bytes).with(0, 512).and_return(mp3_data)
50
50
 
51
- Buffer.stub(:create_empty).with(:uchar, 0)
52
- Buffer.stub(:create_empty).with(:uchar, 512).and_return(output)
51
+ allow(Buffer).to receive(:create_empty).with(:uchar, 0)
52
+ allow(Buffer).to receive(:create_empty).with(:uchar, 512).and_return(output)
53
53
 
54
- id3.v1.should eql mp3_data
54
+ expect(id3.v1).to eql mp3_data
55
55
  end
56
56
  end
57
57
 
58
58
  describe "#v2" do
59
59
  it "creates empty and filled output buffer" do
60
- LAME.stub(:lame_get_id3v2_tag).and_return(1024, 1024)
60
+ allow(LAME).to receive(:lame_get_id3v2_tag).and_return(1024, 1024)
61
61
 
62
62
  # Determine size
63
- Buffer.should_receive(:create_empty).with(:uchar, 0).and_return(stub.as_null_object)
63
+ expect(Buffer).to receive(:create_empty).with(:uchar, 0).and_return(double.as_null_object)
64
64
 
65
65
  # Actual tag
66
- Buffer.should_receive(:create_empty).with(:uchar, 1024).and_return(stub.as_null_object)
66
+ expect(Buffer).to receive(:create_empty).with(:uchar, 1024).and_return(double.as_null_object)
67
67
 
68
68
  id3.v2
69
69
  end
70
70
 
71
71
  it "creates tag" do
72
72
  # Determine size
73
- LAME.should_receive(:lame_get_id3v2_tag) do |flags, buffer, buffer_size|
74
- flags.should eql global_flags
75
- buffer.size.should eql 0
76
- buffer_size.should eql 0
73
+ expect(LAME).to receive(:lame_get_id3v2_tag) do |flags, buffer, buffer_size|
74
+ expect(flags).to eql global_flags
75
+ expect(buffer.size).to eql 0
76
+ expect(buffer_size).to eql 0
77
77
  1024
78
78
  end
79
79
 
80
80
  # Get actual tag
81
- LAME.should_receive(:lame_get_id3v2_tag) do |flags, buffer, buffer_size|
82
- flags.should eql global_flags
83
- buffer.size.should eql 1024
84
- buffer_size.should eql 1024
81
+ expect(LAME).to receive(:lame_get_id3v2_tag) do |flags, buffer, buffer_size|
82
+ expect(flags).to eql global_flags
83
+ expect(buffer.size).to eql 1024
84
+ expect(buffer_size).to eql 1024
85
85
  end
86
86
 
87
87
  id3.v2
88
88
  end
89
89
 
90
90
  it "returns the id3 tag" do
91
- LAME.stub(:lame_get_id3v2_tag).and_return(512, 512)
91
+ allow(LAME).to receive(:lame_get_id3v2_tag).and_return(512, 512)
92
92
 
93
- mp3_data = stub
94
- output = stub
95
- output.stub(:get_bytes).with(0, 512).and_return(mp3_data)
93
+ mp3_data = double("mp3_data")
94
+ output = double("output")
95
+ allow(output).to receive(:get_bytes).with(0, 512).and_return(mp3_data)
96
96
 
97
- Buffer.stub(:create_empty).with(:uchar, 0)
98
- Buffer.stub(:create_empty).with(:uchar, 512).and_return(output)
97
+ allow(Buffer).to receive(:create_empty).with(:uchar, 0)
98
+ allow(Buffer).to receive(:create_empty).with(:uchar, 512).and_return(output)
99
99
 
100
- id3.v2.should eql mp3_data
100
+ expect(id3.v2).to eql mp3_data
101
101
  end
102
102
  end
103
103