doo_dah 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/doo_dah.gemspec +1 -1
- data/lib/doo_dah/zip_output_stream.rb +6 -0
- data/spec/zip_output_stream_spec.rb +32 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/doo_dah.gemspec
CHANGED
@@ -10,6 +10,32 @@ module DooDah
|
|
10
10
|
@entry = stub(:close => nil, :closed? => false)
|
11
11
|
ZipEntry.stub(:new => @entry)
|
12
12
|
end
|
13
|
+
|
14
|
+
describe 'when constructing with a block' do
|
15
|
+
|
16
|
+
it 'should yield itself to the block' do
|
17
|
+
block_parameter = nil
|
18
|
+
zip_output_stream = ZipOutputStream.new(@output_stream) {|output_stream| block_parameter = output_stream }
|
19
|
+
block_parameter.should == zip_output_stream
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should close itself upon return from the block' do
|
23
|
+
zip_output_stream = ZipOutputStream.allocate
|
24
|
+
zip_output_stream.should_receive(:close)
|
25
|
+
zip_output_stream.send(:initialize, @output_stream) {|output_stream| }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should close itself even if an exception is thrown in the block' do
|
29
|
+
zip_output_stream = ZipOutputStream.allocate
|
30
|
+
zip_output_stream.should_receive(:close)
|
31
|
+
BadStuff = Class.new(Exception)
|
32
|
+
begin
|
33
|
+
zip_output_stream.send(:initialize, @output_stream) { |output_stream| raise BadStuff }
|
34
|
+
rescue BadStuff
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
13
39
|
|
14
40
|
describe '#start_entry' do
|
15
41
|
|
@@ -158,6 +184,12 @@ module DooDah
|
|
158
184
|
@zip.write('7 bytes')
|
159
185
|
@zip.current_offset.should == 14
|
160
186
|
end
|
187
|
+
|
188
|
+
it 'should not close itself when constructed without a block' do
|
189
|
+
zip_output_stream = ZipOutputStream.allocate
|
190
|
+
zip_output_stream.should_not_receive(:close)
|
191
|
+
zip_output_stream.send(:initialize, @output_stream)
|
192
|
+
end
|
161
193
|
|
162
194
|
end
|
163
195
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doo_dah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Collas
|