Sha256: 4283b97b39a7fc3b101daff33bceae577eb68ef3c4b05bf2138aec0be7d4e650

Contents?: true

Size: 879 Bytes

Versions: 6

Compression:

Stored size: 879 Bytes

Contents

require 'test_helper'
require 'tins/xt/temp_io'

module Tins
  class TempIOTest < Test::Unit::TestCase
    def test_with_string
      returned = temp_io(content: 'foo') { |io|
        assert_equal 'foo', io.read
        :done
      }
      assert_equal returned, :done
    end

    def test_with_suffixed_name
      returned = temp_io(content: 'foo', name: 'foo.csv') { |io|
        assert_true io.path.end_with?('foo.csv')
        :done
      }
      assert_equal returned, :done
    end

    def test_with_proc
      returned = temp_io(content: -> { 'foo' }) { |io|
        assert_equal 'foo', io.read
        :done
      }
      assert_equal returned, :done
    end

    def test_with_proc_and_io_arg
      returned = temp_io(content: -> io { io << 'foo' }) { |io|
        assert_equal 'foo', io.read
        :done
      }
      assert_equal returned, :done
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/tins-1.16.3/tests/temp_io_test.rb
tdiary-5.0.9 vendor/bundle/gems/tins-1.16.3/tests/temp_io_test.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/tins-1.16.3/tests/temp_io_test.rb
tdiary-5.0.7 vendor/bundle/gems/tins-1.16.3/tests/temp_io_test.rb
tins-1.16.3 tests/temp_io_test.rb
tins-1.16.2 tests/temp_io_test.rb