From 959b16119104420ff5d202288e3fee6705c0c350 Mon Sep 17 00:00:00 2001 From: Nastia Gorokhova-Alekseeva Date: Wed, 29 Dec 2021 21:08:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B8=D0=B2=D0=B0=D0=B5=D0=BC=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=85=D0=BE=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=BE=D0=B2=20=D0=B2=20iostream=5Ftest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/iostream_test.rb | 52 +++++-------------------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/test/iostream_test.rb b/test/iostream_test.rb index 37b0d9a..cb98f14 100644 --- a/test/iostream_test.rb +++ b/test/iostream_test.rb @@ -1,61 +1,21 @@ +# frozen_string_literal: true + require 'test_helper' class IOStreamTest < Test::Unit::TestCase - context "IOStream" do - should "be included in IO, File, Tempfile, and StringIO" do - [IO, File, Tempfile, StringIO].each do |klass| - assert klass.included_modules.include?(IOStream), "Not in #{klass}" - end - end - end - context "A file" do setup do + rebuild_model @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') + @dummy = Dummy.new + @dummy.avatar = @file end teardown { @file.close } - context "that is sent #stream_to" do - - context "and given a String" do - setup do - FileUtils.mkdir_p(File.join(ROOT, 'tmp')) - assert @result = @file.stream_to(File.join(ROOT, 'tmp', 'iostream.string.test')) - end - - should "return a File" do - assert @result.is_a?(File) - end - - should "contain the same data as the original file" do - @file.rewind; @result.rewind - assert_equal @file.read, @result.read - end - end - - context "and given a Tempfile" do - setup do - tempfile = Tempfile.new('iostream.test') - tempfile.binmode - assert @result = @file.stream_to(tempfile) - end - - should "return a Tempfile" do - assert @result.is_a?(Tempfile) - end - - should "contain the same data as the original file" do - @file.rewind; @result.rewind - assert_equal @file.read, @result.read - end - end - - end - context "that is sent #to_tempfile" do setup do - assert @tempfile = @file.to_tempfile + assert @tempfile = @dummy.avatar.to_tempfile(@file) end should "convert it to a Tempfile" do