lame 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +3 -4
  3. data/README.md +51 -17
  4. data/lib/lame.rb +1 -0
  5. data/lib/lame/buffer.rb +1 -1
  6. data/lib/lame/encoder.rb +10 -11
  7. data/lib/lame/encoding/long_buffer_encoder.rb +1 -1
  8. data/lib/lame/encoding/stereo_buffer_encoder.rb +1 -0
  9. data/lib/lame/ffi.rb +2 -0
  10. data/lib/lame/version.rb +1 -1
  11. data/spec/buffer_spec.rb +8 -8
  12. data/spec/configuration_spec.rb +76 -76
  13. data/spec/decoder_spec.rb +34 -34
  14. data/spec/decoding/decoded_frame_spec.rb +7 -7
  15. data/spec/decoding/id3_tag_parser_spec.rb +3 -3
  16. data/spec/decoding/mp3_data_header_parser_spec.rb +21 -21
  17. data/spec/decoding/mpeg_audio_frame_finder_spec.rb +15 -15
  18. data/spec/decoding/mpeg_audio_frame_matcher_spec.rb +2 -2
  19. data/spec/decoding/single_frame_decoder_spec.rb +36 -35
  20. data/spec/decoding/stream_decoder_spec.rb +10 -10
  21. data/spec/delegation_spec.rb +37 -37
  22. data/spec/encoder_spec.rb +100 -100
  23. data/spec/encoding/flusher_spec.rb +16 -16
  24. data/spec/encoding/id3_spec.rb +38 -38
  25. data/spec/encoding/interleaved_buffer_encoder_spec.rb +25 -25
  26. data/spec/encoding/stereo_buffer_encoder_spec.rb +34 -33
  27. data/spec/encoding/vbr_info_spec.rb +16 -16
  28. data/spec/ffi/decode_flags_spec.rb +3 -2
  29. data/spec/ffi/encoding_spec.rb +22 -22
  30. data/spec/ffi/global_flags_spec.rb +159 -157
  31. data/spec/ffi/id3tag_spec.rb +24 -24
  32. data/spec/ffi/mp3_data_spec.rb +3 -3
  33. data/spec/integration/encoding_spec.rb +75 -3
  34. data/spec/integration/id3_tags_spec.rb +18 -18
  35. data/spec/lib/custom_matchers.rb +4 -4
  36. data/spec/lib/wave_file_generator.rb +9 -9
  37. data/spec/spec_helper.rb +0 -1
  38. metadata +38 -60
@@ -6,32 +6,32 @@ module LAME
6
6
 
7
7
  subject(:decoder) { StreamDecoder.new(decode_flags, mp3_data, stream) }
8
8
 
9
- let(:decode_flags) { stub("decode flags") }
10
- let(:mp3_data) { stub("mp3 data") }
9
+ let(:decode_flags) { double("decode flags") }
10
+ let(:mp3_data) { double("mp3 data") }
11
11
 
12
12
  let(:stream) { StringIO.new(stream_string) }
13
13
  let(:stream_string) { "a" * 1024 + "b" * 1024}
14
14
 
15
15
  it "creates a single frame decoder" do
16
- SingleFrameDecoder.should_receive(:new).with(decode_flags, mp3_data)
16
+ expect(SingleFrameDecoder).to receive(:new).with(decode_flags, mp3_data)
17
17
  decoder
18
18
  end
19
19
 
20
20
  it "it passes chunks of stream into the single frame decoder" do
21
- single_frame_decoder = stub
22
- SingleFrameDecoder.stub(:new).and_return(single_frame_decoder)
21
+ single_frame_decoder = double("single_frame_decoder")
22
+ allow(SingleFrameDecoder).to receive(:new).and_return(single_frame_decoder)
23
23
 
24
- single_frame_decoder.should_receive(:decode).exactly(:twice)
24
+ expect(single_frame_decoder).to receive(:decode).exactly(:twice)
25
25
 
26
26
  decoder.each_decoded_frame
27
27
  end
28
28
 
29
29
  it "yields the decoded frame" do
30
- single_frame_decoder = stub
31
- SingleFrameDecoder.stub(:new).and_return(single_frame_decoder)
30
+ single_frame_decoder = double("single frame decoder")
31
+ allow(SingleFrameDecoder).to receive(:new).and_return(single_frame_decoder)
32
32
 
33
- single_frame_decoder.stub(:decode).with("a"*1024).and_yield(:one)
34
- single_frame_decoder.stub(:decode).with("b"*1024).and_yield(:two).and_yield(:three)
33
+ allow(single_frame_decoder).to receive(:decode).with("a"*1024).and_yield(:one)
34
+ allow(single_frame_decoder).to receive(:decode).with("b"*1024).and_yield(:two).and_yield(:three)
35
35
 
36
36
  expect { |block|
37
37
  decoder.each_decoded_frame(&block)
@@ -14,7 +14,7 @@ module LAME
14
14
 
15
15
  describe Delegation do
16
16
 
17
- let(:global_flags) { stub }
17
+ let(:global_flags) { double("global_flags") }
18
18
  subject { FakeEncoder.new }
19
19
 
20
20
  before do
@@ -23,71 +23,71 @@ module LAME
23
23
 
24
24
  context "#delegate_alias_to_lame" do
25
25
  it "delegates #foo= to LAME" do
26
- LAME.should_receive(:lame_set_bar).with(global_flags, anything)
27
- subject.foo = stub
26
+ expect(LAME).to receive(:lame_set_bar).with(global_flags, anything)
27
+ subject.foo = double("delegate")
28
28
  end
29
29
 
30
30
  it "delegates #foo to LAME" do
31
- LAME.should_receive(:lame_get_bar).with(global_flags)
31
+ expect(LAME).to receive(:lame_get_bar).with(global_flags)
32
32
  subject.foo
33
33
  end
34
34
 
35
35
  it "delegates #foo? to LAME" do
36
- LAME.should_receive(:lame_get_bar).with(global_flags)
36
+ expect(LAME).to receive(:lame_get_bar).with(global_flags)
37
37
  subject.foo?
38
38
  end
39
39
  end
40
40
 
41
41
  context "#delegate_to_lame" do
42
42
  it "delegates #baz= to LAME" do
43
- LAME.should_receive(:lame_set_baz).with(global_flags, anything)
44
- subject.baz = stub
43
+ expect(LAME).to receive(:lame_set_baz).with(global_flags, anything)
44
+ subject.baz = double("delegate")
45
45
  end
46
46
 
47
47
  it "delegates #baz to LAME" do
48
- LAME.should_receive(:lame_get_baz).with(global_flags)
48
+ expect(LAME).to receive(:lame_get_baz).with(global_flags)
49
49
  subject.baz
50
50
  end
51
51
 
52
52
  it "delegates #baz? to LAME" do
53
- LAME.should_receive(:lame_get_baz).with(global_flags)
53
+ expect(LAME).to receive(:lame_get_baz).with(global_flags)
54
54
  subject.baz?
55
55
  end
56
56
  end
57
57
 
58
58
  context "#delegate_id3_to_lame" do
59
59
  it "delegates #qux= to LAME" do
60
- LAME.should_receive(:id3tag_set_qux).with(global_flags, anything)
61
- subject.qux = stub
60
+ expect(LAME).to receive(:id3tag_set_qux).with(global_flags, anything)
61
+ subject.qux = double("delegate")
62
62
  end
63
63
  end
64
64
 
65
65
  context "type conversion" do
66
66
  it "converts the input type" do
67
- value = stub
68
- Delegation::TypeConvertor.should_receive(:convert).with(value)
69
- LAME.stub(:lame_set_baz)
67
+ value = double("value")
68
+ expect(Delegation::TypeConvertor).to receive(:convert).with(value)
69
+ allow(LAME).to receive(:lame_set_baz)
70
70
  subject.baz = value
71
71
  end
72
72
 
73
73
  it "passes on converted value to setter" do
74
- value = stub
75
- converted_value = stub
76
- Delegation::TypeConvertor.stub(:convert).and_return(converted_value)
77
- LAME.should_receive(:lame_set_baz).with(global_flags, converted_value)
74
+ value = double("value")
75
+ converted_value = double("converted_value")
76
+ allow(Delegation::TypeConvertor).to receive(:convert).and_return(converted_value)
77
+ expect(LAME).to receive(:lame_set_baz).with(global_flags, converted_value)
78
78
  subject.baz = value
79
79
  end
80
80
 
81
81
  it "converts question mark style getters to return booleans" do
82
- LAME.stub(:lame_get_baz).and_return(0)
83
- Delegation::TypeConvertor.should_receive(:convert_return).with(0)
82
+ allow(LAME).to receive(:lame_get_baz).and_return(0)
83
+ expect(Delegation::TypeConvertor).to receive(:convert_return).with(0)
84
84
  subject.baz?
85
85
  end
86
86
 
87
87
  it "converts question mark style getters to return booleans" do
88
- LAME.stub(:lame_get_baz)
89
- Delegation::TypeConvertor.stub(:convert_return).and_return(false)
90
- subject.baz?.should eql false
88
+ allow(LAME).to receive(:lame_get_baz)
89
+ allow(Delegation::TypeConvertor).to receive(:convert_return).and_return(false)
90
+ expect(subject.baz?).to be_falsy
91
91
  end
92
92
  end
93
93
 
@@ -99,45 +99,45 @@ module LAME
99
99
 
100
100
  describe "#convert" do
101
101
  it "converts true to 1" do
102
- converter.convert(true).should eql 1
102
+ expect(converter.convert(true)).to eql 1
103
103
  end
104
104
 
105
105
  it "converts false to 0" do
106
- converter.convert(false).should eql 0
106
+ expect(converter.convert(false)).to eql 0
107
107
  end
108
108
 
109
109
  it "converts a string to a pointer with correct value" do
110
110
  input = "some string"
111
111
  value = converter.convert(input)
112
- value.should be_a(::FFI::MemoryPointer)
113
- value.get_string(0).should eql input
112
+ expect(value).to be_a(::FFI::MemoryPointer)
113
+ expect(value.get_string(0)).to eql input
114
114
  end
115
115
 
116
116
  it "does not convert other values" do
117
- converter.convert(:foo).should eql :foo
118
- converter.convert(1.2).should eql 1.2
117
+ expect(converter.convert(:foo)).to eql :foo
118
+ expect(converter.convert(1.2)).to eql 1.2
119
119
  end
120
120
  end
121
121
 
122
122
  describe "#convert_return" do
123
123
  it "converts 1 to true" do
124
- converter.convert_return(1).should eql true
124
+ expect(converter.convert_return(1)).to eql true
125
125
  end
126
126
 
127
127
  it "converts 0 to false" do
128
- converter.convert_return(0).should eql false
128
+ expect(converter.convert_return(0)).to eql false
129
129
  end
130
130
 
131
131
  it "converts 0.0 to false" do
132
- converter.convert_return(0.0).should eql false
132
+ expect(converter.convert_return(0.0)).to eql false
133
133
  end
134
134
 
135
135
  it "returns truthy to true" do
136
- converter.convert_return(:truthy).should eql true
137
- converter.convert_return("truthy").should eql true
138
- converter.convert_return(Object).should eql true
139
- converter.convert_return(Object.new).should eql true
140
- converter.convert_return(4.2).should eql true
136
+ expect(converter.convert_return(:truthy)).to eql true
137
+ expect(converter.convert_return("truthy")).to eql true
138
+ expect(converter.convert_return(Object)).to eql true
139
+ expect(converter.convert_return(Object.new)).to eql true
140
+ expect(converter.convert_return(4.2)).to eql true
141
141
  end
142
142
  end
143
143
 
@@ -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