Skip to content

Commit f930ed9

Browse files
authored
Merge pull request #5 from wallarm/dev
Fix default tempfile mode and fix flacky tests
2 parents bb1c7c3 + a2b4628 commit f930ed9

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

lib/cloud_storage/objects/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def size
1313
@internal.size
1414
end
1515

16-
def download(local_file = Tempfile.new)
16+
def download(local_file = Tempfile.new('cloud', binmode: true))
1717
internal_download(local_file).tap(&:rewind)
1818
end
1919

lib/cloud_storage/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module CloudStorage
4-
VERSION = '0.1.0'
4+
VERSION = '0.1.1'
55
end

spec/cloud_storage/wrappers/gcs_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,19 @@
148148
context 'when file exists' do
149149
let(:file) { File.open('spec/fixtures/test.txt', 'rb') }
150150
let!(:obj) { cli.upload_file(key: 'test5.txt', file: file) }
151+
let(:tmp) { cli.find('test5.txt').download }
151152

152153
after do
153154
file.close
154155

155156
obj.delete!
157+
158+
tmp.close
159+
tmp.unlink
156160
end
157161

158162
it do
159-
expect(cli.find('test5.txt').download.read).to eq("This is a test upload\n")
163+
expect(tmp.read).to eq("This is a test upload\n")
160164
end
161165
end
162166

spec/cloud_storage/wrappers/s3_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@
141141
context 'when file exists' do
142142
let(:file) { File.open('spec/fixtures/test.txt', 'rb') }
143143
let!(:obj) { cli.upload_file(key: 'test5.txt', file: file) }
144+
let(:tmp) { cli.find('test5.txt').download }
144145

145146
after do
146147
file.close
147148

148149
obj.delete!
149-
end
150150

151-
it do
152-
expect(cli.find('test5.txt').download.read).to eq("This is a test upload\n")
151+
tmp.close
152+
tmp.unlink
153153
end
154+
155+
it { expect(tmp.read).to eq("This is a test upload\n") }
154156
end
155157

156158
context 'when file does not exists' do

0 commit comments

Comments
 (0)