spec/integration/file_upload_spec.rb in rmega-0.2.0 vs spec/integration/file_upload_spec.rb in rmega-0.2.1
- old
+ new
@@ -1,31 +1,28 @@
require 'integration_spec_helper'
describe 'File upload' do
- if account_file_exists?
+ if account?
- before(:all) { @storage = login }
+ before(:all) do
+ @storage = login
+ end
- let(:name) { "test_file" }
+ [12, 6_000].each do |size|
- let(:path) { File.join(temp_folder, name)}
-
- [12, 1_024_000].each do |size|
context "when a file (#{size} bytes) is uploaded" do
- before do
- File.open(path, 'wb') { |f| f.write(OpenSSL::Random.random_bytes(size)) }
- @file = @storage.root.upload(path)
- end
+ let(:path) { "#{temp_folder}/testfile_#{SecureRandom.hex(6)}" }
- it 'it can be found as a file node' do
- found_node = @storage.root.files.find { |f| f.handle == @file.handle }
- expect(found_node).not_to be_nil
- end
+ let(:content) { SecureRandom.random_bytes(size) }
- after do
- @file.delete if @file
+ it 'is found' do
+ File.write(path, content)
+ file = @storage.root.upload(path)
+ file = @storage.root.files.find { |f| f.handle == file.handle }
+ file.delete
+ expect(file).not_to be_nil
end
end
end
end
end