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
@@ -4,84 +4,84 @@ module LAME
4
4
  describe Configuration do
5
5
 
6
6
  context "intialization" do
7
- let(:global_flags) { stub }
7
+ let(:global_flags) { double("global_flags") }
8
8
 
9
9
  subject(:configuration) { Configuration.new(global_flags) }
10
10
 
11
11
  it "initializes with global flags" do
12
- configuration.global_flags.should eql global_flags
12
+ expect(configuration.global_flags).to eql global_flags
13
13
  end
14
14
 
15
15
  it "initializes a AsmOptimization configuration object" do
16
- Configuration::AsmOptimization.should_receive(:new).with(global_flags)
16
+ expect(Configuration::AsmOptimization).to receive(:new).with(global_flags)
17
17
  configuration.asm_optimization
18
18
  end
19
19
 
20
20
  it "memoizes one AsmOptimization configuration object" do
21
- Configuration::AsmOptimization.stub(:new).and_return(stub)
22
- Configuration::AsmOptimization.should_receive(:new).exactly(:once)
21
+ allow(Configuration::AsmOptimization).to receive(:new).and_return(double)
22
+ expect(Configuration::AsmOptimization).to receive(:new).exactly(:once)
23
23
  2.times { configuration.asm_optimization }
24
24
  end
25
25
 
26
26
  it "initializes a Id3 configuration object" do
27
- Configuration::Id3.should_receive(:new).with(global_flags)
27
+ expect(Configuration::Id3).to receive(:new).with(global_flags)
28
28
  configuration.id3
29
29
  end
30
30
 
31
31
  it "memoizes one Id3 configuration object" do
32
- Configuration::Id3.stub(:new).and_return(stub)
33
- Configuration::Id3.should_receive(:new).exactly(:once)
32
+ allow(Configuration::Id3).to receive(:new).and_return(double)
33
+ expect(Configuration::Id3).to receive(:new).exactly(:once)
34
34
  2.times { configuration.id3 }
35
35
  end
36
36
 
37
37
  it "initializes a Quantization configuration object" do
38
- Configuration::Quantization.should_receive(:new).with(global_flags)
38
+ expect(Configuration::Quantization).to receive(:new).with(global_flags)
39
39
  configuration.quantization
40
40
  end
41
41
 
42
42
  it "memoizes one Quantization configuration object" do
43
- Configuration::Quantization.stub(:new).and_return(stub)
44
- Configuration::Quantization.should_receive(:new).exactly(:once)
43
+ allow(Configuration::Quantization).to receive(:new).and_return(double)
44
+ expect(Configuration::Quantization).to receive(:new).exactly(:once)
45
45
  2.times { configuration.quantization }
46
46
  end
47
47
 
48
48
  it "initializes a VBR configuration object" do
49
- Configuration::VBR.should_receive(:new).with(global_flags)
49
+ expect(Configuration::VBR).to receive(:new).with(global_flags)
50
50
  configuration.vbr
51
51
  end
52
52
 
53
53
  it "memoizes one VBR configuration object" do
54
- Configuration::VBR.stub(:new).and_return(stub)
55
- Configuration::VBR.should_receive(:new).exactly(:once)
54
+ allow(Configuration::VBR).to receive(:new).and_return(double)
55
+ expect(Configuration::VBR).to receive(:new).exactly(:once)
56
56
  2.times { configuration.vbr }
57
57
  end
58
58
 
59
59
  it "initializes a Filtering configuration object" do
60
- Configuration::Filtering.should_receive(:new).with(global_flags)
60
+ expect(Configuration::Filtering).to receive(:new).with(global_flags)
61
61
  configuration.filtering
62
62
  end
63
63
 
64
64
  it "memoizes one Filtering configuration object" do
65
- Configuration::Filtering.stub(:new).and_return(stub)
66
- Configuration::Filtering.should_receive(:new).exactly(:once)
65
+ allow(Configuration::Filtering).to receive(:new).and_return(double)
66
+ expect(Configuration::Filtering).to receive(:new).exactly(:once)
67
67
  2.times { configuration.filtering }
68
68
  end
69
69
 
70
70
  it "initializes a PsychoAcoustics configuration object" do
71
- Configuration::PsychoAcoustics.should_receive(:new).with(global_flags)
71
+ expect(Configuration::PsychoAcoustics).to receive(:new).with(global_flags)
72
72
  configuration.psycho_acoustics
73
73
  end
74
74
 
75
75
  it "memoizes one PsychoAcoustics configuration object" do
76
- Configuration::PsychoAcoustics.stub(:new).and_return(stub)
77
- Configuration::PsychoAcoustics.should_receive(:new).exactly(:once)
76
+ allow(Configuration::PsychoAcoustics).to receive(:new).and_return(double)
77
+ expect(Configuration::PsychoAcoustics).to receive(:new).exactly(:once)
78
78
  2.times { configuration.psycho_acoustics }
79
79
  end
80
80
 
81
81
  context "Id3" do
82
82
 
83
83
  it "initializes the Id3 tag" do
84
- LAME.should_receive(:id3tag_init).with(global_flags)
84
+ expect(LAME).to receive(:id3tag_init).with(global_flags)
85
85
  Configuration::Id3.new(global_flags)
86
86
  end
87
87
 
@@ -89,17 +89,17 @@ module LAME
89
89
 
90
90
  describe "#apply! / #applied?" do
91
91
  it "is not applied by default" do
92
- configuration.should_not be_applied
92
+ expect(configuration).not_to be_applied
93
93
  end
94
94
 
95
95
  it "applies the configuration" do
96
- LAME.should_receive(:lame_init_params).with(global_flags)
96
+ expect(LAME).to receive(:lame_init_params).with(global_flags)
97
97
  configuration.apply!
98
- configuration.should be_applied
98
+ expect(configuration).to be_applied
99
99
  end
100
100
 
101
101
  it "raises an error if configuration could not be applied" do
102
- LAME.stub(:lame_init_params).and_return(-1)
102
+ allow(LAME).to receive(:lame_init_params).and_return(-1)
103
103
  expect {
104
104
  configuration.apply!
105
105
  }.to raise_error(ConfigurationError)
@@ -109,12 +109,12 @@ module LAME
109
109
  describe "#framesize" do
110
110
 
111
111
  it "gets framesize from LAME if configuration was applied" do
112
- LAME.stub(:lame_init_params)
112
+ allow(LAME).to receive(:lame_init_params)
113
113
  configuration.apply!
114
114
 
115
- LAME.stub(:lame_get_framesize).and_return(42)
116
- LAME.should_receive(:lame_get_framesize).with(global_flags)
117
- configuration.framesize.should eql 42
115
+ allow(LAME).to receive(:lame_get_framesize).and_return(42)
116
+ expect(LAME).to receive(:lame_get_framesize).with(global_flags)
117
+ expect(configuration.framesize).to eql 42
118
118
  end
119
119
 
120
120
  it "raises an error if configuration was not applied" do
@@ -124,12 +124,12 @@ module LAME
124
124
  end
125
125
 
126
126
  it "calculates the output buffer size based on the framesize" do
127
- LAME.stub(:lame_init_params)
127
+ allow(LAME).to receive(:lame_init_params)
128
128
  configuration.apply!
129
129
 
130
- LAME.stub(:lame_get_framesize).and_return(1152)
131
- LAME.should_receive(:lame_get_framesize).with(global_flags)
132
- configuration.output_buffer_size.should eql 8640
130
+ allow(LAME).to receive(:lame_get_framesize).and_return(1152)
131
+ expect(LAME).to receive(:lame_get_framesize).with(global_flags)
132
+ expect(configuration.output_buffer_size).to eql 8640
133
133
  end
134
134
 
135
135
  end
@@ -148,7 +148,7 @@ module LAME
148
148
  #
149
149
  context "set/get delegation" do
150
150
 
151
- let(:global_flags) { stub(GlobalFlags) }
151
+ let(:global_flags) { double(GlobalFlags) }
152
152
  subject(:configuration) { Configuration.new(global_flags) }
153
153
 
154
154
  context "basic fields" do
@@ -183,8 +183,8 @@ module LAME
183
183
  it { should delegate(:emphasis) }
184
184
 
185
185
  it "delegates #preset= to LAME.lame_set_preset" do
186
- LAME.should_receive(:lame_set_preset).with(global_flags, anything)
187
- configuration.preset = stub
186
+ expect(LAME).to receive(:lame_set_preset).with(global_flags, anything)
187
+ configuration.preset = double
188
188
  end
189
189
 
190
190
  end
@@ -193,17 +193,17 @@ module LAME
193
193
  subject(:asm_optimization) { configuration.asm_optimization }
194
194
 
195
195
  it "delegates #mmx to LAME.lame_set_asm_optimizations" do
196
- LAME.should_receive(:lame_set_asm_optimizations).with(global_flags, :MMX, 1)
196
+ expect(LAME).to receive(:lame_set_asm_optimizations).with(global_flags, :MMX, 1)
197
197
  asm_optimization.mmx = true
198
198
  end
199
199
 
200
200
  it "delegates #amd_3dnow to LAME.lame_set_asm_optimizations" do
201
- LAME.should_receive(:lame_set_asm_optimizations).with(global_flags, :AMD_3DNOW, 1)
201
+ expect(LAME).to receive(:lame_set_asm_optimizations).with(global_flags, :AMD_3DNOW, 1)
202
202
  asm_optimization.amd_3dnow = true
203
203
  end
204
204
 
205
205
  it "delegates #sse to LAME.lame_set_asm_optimizations" do
206
- LAME.should_receive(:lame_set_asm_optimizations).with(global_flags, :SSE, 1)
206
+ expect(LAME).to receive(:lame_set_asm_optimizations).with(global_flags, :SSE, 1)
207
207
  asm_optimization.sse = true
208
208
  end
209
209
  end
@@ -215,37 +215,37 @@ module LAME
215
215
  it { should delegate(:write_automatic).to(:write_id3tag_automatic) }
216
216
 
217
217
  before do
218
- LAME.stub(:id3tag_init)
218
+ allow(LAME).to receive(:id3tag_init)
219
219
  end
220
220
 
221
221
  it "delegates #v2= to LAME.id3tag_add_v2" do
222
- LAME.should_receive(:id3tag_add_v2).with(global_flags)
222
+ expect(LAME).to receive(:id3tag_add_v2).with(global_flags)
223
223
  id3.v2 = true
224
224
  end
225
225
 
226
226
  it "delegates #v1_only= to LAME.id3tag_v1_only" do
227
- LAME.should_receive(:id3tag_v1_only).with(global_flags)
227
+ expect(LAME).to receive(:id3tag_v1_only).with(global_flags)
228
228
  id3.v1_only = true
229
229
  end
230
230
 
231
231
  it "delegates #v2_only= to LAME.id3tag_v2_only" do
232
- LAME.should_receive(:id3tag_v2_only).with(global_flags)
232
+ expect(LAME).to receive(:id3tag_v2_only).with(global_flags)
233
233
  id3.v2_only = true
234
234
  end
235
235
 
236
236
  it "delegates #v1_space= to LAME.id3tag_v1_space" do
237
- LAME.should_receive(:id3tag_space_v1).with(global_flags)
237
+ expect(LAME).to receive(:id3tag_space_v1).with(global_flags)
238
238
  id3.v1_space = true
239
239
  end
240
240
 
241
241
  it "delegates #v2_padding= to LAME.id3tag_pad_v2" do
242
- LAME.should_receive(:id3tag_pad_v2).with(global_flags)
242
+ expect(LAME).to receive(:id3tag_pad_v2).with(global_flags)
243
243
  id3.v2_padding = true
244
244
  end
245
245
 
246
246
  it "delegates #v2_padding_size= to LAME.id3tag_set_pad" do
247
- value = stub
248
- LAME.should_receive(:id3tag_set_pad).with(global_flags, value)
247
+ value = double
248
+ expect(LAME).to receive(:id3tag_set_pad).with(global_flags, value)
249
249
  id3.v2_padding_size = value
250
250
  end
251
251
 
@@ -253,10 +253,10 @@ module LAME
253
253
  [ :title, :artist, :album, :year, :comment ].each do |field|
254
254
 
255
255
  it "sets the #{field} with string buffer" do
256
- LAME.should_receive(:"id3tag_set_#{field}") do |flags, string_buffer|
257
- flags.should eql global_flags
258
- string_buffer.should be_a(::FFI::MemoryPointer)
259
- string_buffer.get_string(0).should eql "Some #{field}"
256
+ expect(LAME).to receive(:"id3tag_set_#{field}") do |flags, string_buffer|
257
+ expect(flags).to eql global_flags
258
+ expect(string_buffer).to be_a(::FFI::MemoryPointer)
259
+ expect(string_buffer.get_string(0)).to eql "Some #{field}"
260
260
  end
261
261
  id3.send(:"#{field}=", "Some #{field}")
262
262
  end
@@ -264,37 +264,37 @@ module LAME
264
264
  end
265
265
 
266
266
  it "sets the track" do
267
- LAME.should_receive(:"id3tag_set_track") do |flags, value|
268
- flags.should eql global_flags
269
- value.should eql 42
267
+ expect(LAME).to receive(:"id3tag_set_track") do |flags, value|
268
+ expect(flags).to eql global_flags
269
+ expect(value).to eql 42
270
270
  end
271
271
  id3.track = 42
272
272
  end
273
273
 
274
274
  it "sets the genre by name" do
275
- LAME.should_receive(:id3tag_set_genre) do |flags, value|
276
- flags.should eql global_flags
277
- value.should be_a(::FFI::MemoryPointer)
278
- value.get_string(0).should eql "147"
275
+ expect(LAME).to receive(:id3tag_set_genre) do |flags, value|
276
+ expect(flags).to eql global_flags
277
+ expect(value).to be_a(::FFI::MemoryPointer)
278
+ expect(value.get_string(0)).to eql "147"
279
279
  end
280
280
  id3.genre = "SynthPop"
281
281
  end
282
282
 
283
283
  it "sets the genre by id" do
284
- LAME.should_receive(:id3tag_set_genre) do |flags, value|
285
- flags.should eql global_flags
286
- value.should be_a(::FFI::MemoryPointer)
287
- value.get_string(0).should eql "81"
284
+ expect(LAME).to receive(:id3tag_set_genre) do |flags, value|
285
+ expect(flags).to eql global_flags
286
+ expect(value).to be_a(::FFI::MemoryPointer)
287
+ expect(value.get_string(0)).to eql "81"
288
288
  end
289
289
 
290
290
  id3.genre = 81
291
291
  end
292
292
 
293
293
  it "sets non-standard genre name" do
294
- LAME.should_receive(:id3tag_set_genre) do |flags, value|
295
- flags.should eql global_flags
296
- value.should be_a(::FFI::MemoryPointer)
297
- value.get_string(0).should eql "Ruby FFI Rock"
294
+ expect(LAME).to receive(:id3tag_set_genre) do |flags, value|
295
+ expect(flags).to eql global_flags
296
+ expect(value).to be_a(::FFI::MemoryPointer)
297
+ expect(value.get_string(0)).to eql "Ruby FFI Rock"
298
298
  end
299
299
  id3.genre = "Ruby FFI Rock"
300
300
  end
@@ -312,23 +312,23 @@ module LAME
312
312
  it { should delegate(:msfix) }
313
313
 
314
314
  it "delegates #reservoir= to LAME.lame_set_disable_reservoir" do
315
- LAME.should_receive(:lame_set_disable_reservoir).with(global_flags, 1)
315
+ expect(LAME).to receive(:lame_set_disable_reservoir).with(global_flags, 1)
316
316
  quantization.reservoir = false
317
317
  end
318
318
 
319
319
  it "delegates #reservoir to LAME.lame_get_disable_reservoir" do
320
- LAME.should_receive(:lame_get_disable_reservoir).with(global_flags)
320
+ expect(LAME).to receive(:lame_get_disable_reservoir).with(global_flags)
321
321
  quantization.reservoir
322
322
  end
323
323
 
324
324
  it "delegates #reservoir? to LAME.lame_get_disable_reservoir" do
325
- LAME.should_receive(:lame_get_disable_reservoir).with(global_flags)
325
+ expect(LAME).to receive(:lame_get_disable_reservoir).with(global_flags)
326
326
  quantization.reservoir?
327
327
  end
328
328
 
329
329
  it "converts the return value 0 for #reservoir? to false" do
330
- LAME.stub(:lame_get_disable_reservoir).and_return(0)
331
- quantization.reservoir?.should be_false
330
+ allow(LAME).to receive(:lame_get_disable_reservoir).and_return(0)
331
+ expect(quantization.reservoir?).to be_falsy
332
332
  end
333
333
  end
334
334
 
@@ -365,23 +365,23 @@ module LAME
365
365
  it { should delegate(:athaa_sensitivity) }
366
366
 
367
367
  it "delegates #ath= to LAME.lame_set_noATH" do
368
- LAME.should_receive(:lame_set_noATH).with(global_flags, 1)
368
+ expect(LAME).to receive(:lame_set_noATH).with(global_flags, 1)
369
369
  psycho_acoustics.ath = false
370
370
  end
371
371
 
372
372
  it "delegates #ath to LAME.lame_get_noATH" do
373
- LAME.should_receive(:lame_get_noATH).with(global_flags)
373
+ expect(LAME).to receive(:lame_get_noATH).with(global_flags)
374
374
  psycho_acoustics.ath
375
375
  end
376
376
 
377
377
  it "delegates #ath? to LAME.lame_get_noATH" do
378
- LAME.should_receive(:lame_get_noATH).with(global_flags)
378
+ expect(LAME).to receive(:lame_get_noATH).with(global_flags)
379
379
  psycho_acoustics.ath?
380
380
  end
381
381
 
382
382
  it "converts the return value 0 for #ath? to true" do
383
- LAME.stub(:lame_get_noATH).and_return(0)
384
- psycho_acoustics.ath?.should be_true
383
+ allow(LAME).to receive(:lame_get_noATH).and_return(0)
384
+ expect(psycho_acoustics.ath?).to be_truthy
385
385
  end
386
386
  end
387
387
 
data/spec/decoder_spec.rb CHANGED
@@ -3,16 +3,16 @@ require 'spec_helper'
3
3
  module LAME
4
4
  describe Decoder do
5
5
 
6
- let(:decode_flags) { stub("decode flags") }
7
- let(:mp3_file) { stub("mp3 file") }
8
- let(:id3_tag_parser) { stub("id3 tag parser", :skip! => nil) }
9
- let(:mp3_data_header_parser) { stub("mp3 data header parser", :parse! => nil) }
6
+ let(:decode_flags) { double("decode flags") }
7
+ let(:mp3_file) { double("mp3 file") }
8
+ let(:id3_tag_parser) { double("id3 tag parser", :skip! => nil) }
9
+ let(:mp3_data_header_parser) { double("mp3 data header parser", :parse! => nil) }
10
10
 
11
11
  # Stub away all collaborators:
12
12
  before do
13
- Decoding::Id3TagParser.stub(:new).and_return(id3_tag_parser)
14
- Decoding::Mp3DataHeaderParser.stub(:new).and_return(mp3_data_header_parser)
15
- FFI::DecodeFlags.stub(:new).and_return(decode_flags)
13
+ allow(Decoding::Id3TagParser).to receive(:new).and_return(id3_tag_parser)
14
+ allow(Decoding::Mp3DataHeaderParser).to receive(:new).and_return(mp3_data_header_parser)
15
+ allow(FFI::DecodeFlags).to receive(:new).and_return(decode_flags)
16
16
  end
17
17
 
18
18
  subject(:decoder) { Decoder.new(mp3_file) }
@@ -20,74 +20,74 @@ module LAME
20
20
  context "initialization" do
21
21
 
22
22
  it "initializes DecodeFlags" do
23
- FFI::DecodeFlags.should_receive(:new)
23
+ expect(FFI::DecodeFlags).to receive(:new)
24
24
  Decoder.new(mp3_file)
25
25
  end
26
26
 
27
27
  it "has the DecodeFlags" do
28
- decode_flags = stub
29
- FFI::DecodeFlags.stub(:new).and_return(decode_flags)
30
- decoder.decode_flags.should eql decode_flags
28
+ decode_flags = double("decode_flags")
29
+ allow(FFI::DecodeFlags).to receive(:new).and_return(decode_flags)
30
+ expect(decoder.decode_flags).to eql decode_flags
31
31
  end
32
32
 
33
33
  it "has the mp3 file path" do
34
- decoder.mp3_file.should eql mp3_file
34
+ expect(decoder.mp3_file).to eql mp3_file
35
35
  end
36
36
 
37
37
  it "skips the id3 offset" do
38
- Decoding::Id3TagParser.should_receive(:new).with(mp3_file)
39
- id3_tag_parser.should_receive(:skip!)
38
+ expect(Decoding::Id3TagParser).to receive(:new).with(mp3_file)
39
+ expect(id3_tag_parser).to receive(:skip!)
40
40
 
41
41
  decoder
42
42
  end
43
43
 
44
44
  it "parses the mp3 data header" do
45
- parser = stub
46
- mp3_data = stub
47
- Decoding::Mp3DataHeaderParser.should_receive(:new).with(decode_flags, mp3_file).and_return(parser)
48
- parser.should_receive(:parse!).and_return(mp3_data)
45
+ parser = double("parser")
46
+ mp3_data = double("mp3_data")
47
+ expect(Decoding::Mp3DataHeaderParser).to receive(:new).with(decode_flags, mp3_file).and_return(parser)
48
+ expect(parser).to receive(:parse!).and_return(mp3_data)
49
49
 
50
- decoder.mp3_data.should eql mp3_data
50
+ expect(decoder.mp3_data).to eql mp3_data
51
51
  end
52
52
 
53
53
  end
54
54
 
55
55
  context "after initialization" do
56
56
 
57
- let(:mp3_data) { stub("mp3 data") }
57
+ let(:mp3_data) { double("mp3 data") }
58
58
 
59
59
  # stubbing galore!
60
60
  before do
61
- FFI::DecodeFlags.stub(:new).and_return(decode_flags)
61
+ allow(FFI::DecodeFlags).to receive(:new).and_return(decode_flags)
62
62
 
63
- parser = stub
64
- Decoding::Mp3DataHeaderParser.stub(:new).and_return(parser)
65
- parser.stub(:parse!).and_return(mp3_data)
63
+ parser = double("parser")
64
+ allow(Decoding::Mp3DataHeaderParser).to receive(:new).and_return(parser)
65
+ allow(parser).to receive(:parse!).and_return(mp3_data)
66
66
  end
67
67
 
68
68
  describe "#each_decoded_frame" do
69
69
 
70
- let(:stream_decoder) { stub }
70
+ let(:stream_decoder) { double("stream_decoder") }
71
71
  before do
72
- Decoding::StreamDecoder.stub(:new).and_return(stream_decoder)
72
+ allow(Decoding::StreamDecoder).to receive(:new).and_return(stream_decoder)
73
73
  end
74
74
 
75
75
  it "initializes a stream decoder with mp3 file and mp3 data" do
76
- stream_decoder.stub(:each_decoded_frame)
76
+ allow(stream_decoder).to receive(:each_decoded_frame)
77
77
 
78
- Decoding::StreamDecoder.should_receive(:new).with(decode_flags, mp3_data, mp3_file)
78
+ expect(Decoding::StreamDecoder).to receive(:new).with(decode_flags, mp3_data, mp3_file)
79
79
 
80
80
  decoder.each_decoded_frame
81
81
  end
82
82
 
83
83
  it "delegates to a stream decoder" do
84
- stream_decoder.should_receive(:each_decoded_frame)
84
+ expect(stream_decoder).to receive(:each_decoded_frame)
85
85
 
86
86
  decoder.each_decoded_frame
87
87
  end
88
88
 
89
89
  it "re-yields the stream decoder's yield" do
90
- stream_decoder.stub(:each_decoded_frame).and_yield(:one).and_yield(:two)
90
+ allow(stream_decoder).to receive(:each_decoded_frame).and_yield(:one).and_yield(:two)
91
91
 
92
92
  expect { |block|
93
93
  decoder.each_decoded_frame(&block)
@@ -99,8 +99,8 @@ module LAME
99
99
  describe "#channel_mode" do
100
100
 
101
101
  it "delegates to mp3_data" do
102
- mp3_data.should_receive(:channel_mode).and_return(:stereo)
103
- decoder.channel_mode.should eql :stereo
102
+ expect(mp3_data).to receive(:channel_mode).and_return(:stereo)
103
+ expect(decoder.channel_mode).to eql :stereo
104
104
  end
105
105
 
106
106
  end
@@ -108,8 +108,8 @@ module LAME
108
108
  describe "#sample_rate" do
109
109
 
110
110
  it "delegates to mp3_data" do
111
- mp3_data.should_receive(:sample_rate).and_return(44100)
112
- decoder.sample_rate.should eql 44100
111
+ allow(mp3_data).to receive(:sample_rate).and_return(44100)
112
+ expect(decoder.sample_rate).to eql 44100
113
113
  end
114
114
 
115
115
  end
@@ -5,13 +5,13 @@ module LAME
5
5
  describe DecodedFrame do
6
6
 
7
7
  it "is initialized with left and right samples" do
8
- left = stub
9
- right = stub
8
+ left = double("left")
9
+ right = double("right")
10
10
 
11
11
  decoded_frame = DecodedFrame.new(left, right)
12
12
 
13
- decoded_frame.left.should eql left
14
- decoded_frame.right.should eql right
13
+ expect(decoded_frame.left).to eql left
14
+ expect(decoded_frame.right).to eql right
15
15
  end
16
16
 
17
17
  it "can be built with FFI Buffers" do
@@ -23,8 +23,8 @@ module LAME
23
23
 
24
24
  decoded_frame = DecodedFrame.from_short_buffers(left_buffer, right_buffer)
25
25
 
26
- decoded_frame.left.should eql [1,2,3,4]
27
- decoded_frame.right.should eql [5,6,7,8]
26
+ expect(decoded_frame.left).to eql [1,2,3,4]
27
+ expect(decoded_frame.right).to eql [5,6,7,8]
28
28
  end
29
29
 
30
30
  describe "#samples" do
@@ -35,7 +35,7 @@ module LAME
35
35
 
36
36
  decoded_frame = DecodedFrame.new(left, right)
37
37
 
38
- decoded_frame.samples.should eql [[1,5],[2,6],[3,7],[4,8]]
38
+ expect(decoded_frame.samples).to eql [[1,5],[2,6],[3,7],[4,8]]
39
39
  end
40
40
  end
41
41
 
@@ -21,13 +21,13 @@ module LAME
21
21
 
22
22
  it "seeks the file until after the id3 tag" do
23
23
  parser.skip!
24
- stream.pos.should eql 351
24
+ expect(stream.pos).to eql 351
25
25
  end
26
26
 
27
27
  it "start from the start of the stream" do
28
28
  stream.seek(42)
29
29
  parser.skip!
30
- stream.pos.should eql 351
30
+ expect(stream.pos).to eql 351
31
31
  end
32
32
  end
33
33
 
@@ -43,7 +43,7 @@ module LAME
43
43
 
44
44
  it "does not seek the stream if no header is present" do
45
45
  parser.skip!
46
- stream.pos.should eql 0
46
+ expect(stream.pos).to eql 0
47
47
  end
48
48
  end
49
49