PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/file/test_writelines.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 22 lines | 20 code | 2 blank | 0 comment | 0 complexity | 06a7497f71f81094c39247c4e71d55f4 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. require 'facets/file/write'
  2. require 'test/unit'
  3. require 'tempfile'
  4. class TC_File_Writelines < Test::Unit::TestCase
  5. def setup
  6. tmp_dir = Dir::tmpdir # ENV["TMP"] || ENV["TEMP"] || "/tmp"
  7. raise "Can't find temporary directory" unless File.directory?(tmp_dir)
  8. @path = File.join(tmp_dir, "ruby_io_test")
  9. end
  10. # Test File.writelines
  11. def test_file_writelines
  12. data_in = %w[one two three four five]
  13. File.writelines(@path, data_in)
  14. data_out = File.readlines(@path) # This is standard class method.
  15. assert_equal(data_in, data_out.map { |l| l.chomp })
  16. end
  17. end