test/file_reader_test.rb in iostreams-0.14.0 vs test/file_reader_test.rb in iostreams-0.15.0

- old
+ new

@@ -1,32 +1,33 @@ require_relative 'test_helper' -# Unit Test for IOStreams::File -module Streams - class FileReaderTest < Minitest::Test - describe IOStreams::File::Reader do - before do - @file_name = File.join(File.dirname(__FILE__), 'files', 'text.txt') - @data = File.read(@file_name) - end +class FileReaderTest < Minitest::Test + describe IOStreams::File::Reader do + let :file_name do + File.join(File.dirname(__FILE__), 'files', 'text.txt') + end - describe '.open' do - it 'file' do - result = IOStreams::File::Reader.open(@file_name) do |io| - io.read - end - assert_equal @data, result + let :raw do + File.read(file_name) + end + + describe '.open' do + it 'file' do + result = IOStreams::File::Reader.open(file_name) do |io| + io.read end + assert_equal raw, result + end - it 'stream' do - result = File.open(@file_name) do |file| + it 'does not support streams' do + assert_raises ArgumentError do + File.open(file_name) do |file| IOStreams::File::Reader.open(file) do |io| io.read end end - assert_equal @data, result end end - end + end end