Sha256: 01fc1dd483f9e46350623623d0247ed0989beeb7720cbc36de0ff931c49d6e7d
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require_relative 'test_helper' class FileWriterTest < Minitest::Test describe IOStreams::File::Writer do let :file_name do File.join(File.dirname(__FILE__), 'files', 'text.txt') end let :raw do File.read(file_name) end describe '.open' do it 'file' do temp_file = Tempfile.new('rocket_job') file_name = temp_file.to_path IOStreams::File::Writer.open(file_name) do |io| io.write(raw) end result = File.read(file_name) assert_equal raw, result end it 'cleans up failed upload' do temp_file = Tempfile.new('rocket_job') file_name = temp_file.to_path begin IOStreams::File::Writer.open(file_name) do |io| io.write("hello world") assert File.exist?(file_name) raise(ArgumentError, "Oh no") end rescue ArgumentError end refute File.exist?(file_name) end it 'does not support streams' do io_string = StringIO.new assert_raises ArgumentError do IOStreams::File::Writer.open(io_string) do |io| io.write(raw) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.20.3 | test/file_writer_test.rb |