Sha256: 68de754c3becd4322e574c5886b6486eb109ab62602efb6c42147807fe67eba9
Contents?: true
Size: 1.72 KB
Versions: 19
Compression:
Stored size: 1.72 KB
Contents
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb') require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1') require 'scout/open' class TestOpenUtil < Test::Unit::TestCase def test_read_grep content =<<-EOF 1 2 3 4 EOF TmpFile.with_file(content) do |file| sum = 0 Open.read(file, :grep => '^1\|3') do |line| sum += line.to_i end assert_equal(1 + 3, sum) end TmpFile.with_file(content) do |file| sum = 0 Open.read(file, :grep => ["1","3"]) do |line| sum += line.to_i end assert_equal(1 + 3, sum) end end def test_read_grep_invert content =<<-EOF 1 2 3 4 EOF TmpFile.with_file(content) do |file| sum = 0 Open.read(file, :grep => '^1\|3', :invert_grep => true) do |line| sum += line.to_i end assert_equal(2 + 4, sum) end TmpFile.with_file(content) do |file| sum = 0 Open.read(file, :grep => ["1","3"]) do |line| sum += line.to_i end assert_equal(1 + 3, sum) end end def test_ln_s TmpFile.with_file do |directory| Path.setup(directory) file1 = directory.subdir1.file file2 = directory.subdir2.file Open.write(file1, "TEST") Open.ln_s file1, file2 assert_equal "TEST", Open.read(file2) Open.write(file1, "TEST2") assert_equal "TEST2", Open.read(file2) end end def test_ln_h TmpFile.with_file do |directory| Path.setup(directory) file1 = directory.subdir1.file file2 = directory.subdir2.file Open.write(file1, "TEST") Open.ln_s file1, file2 assert_equal "TEST", Open.read(file2) Open.write(file1, "TEST2") assert_equal "TEST2", Open.read(file2) end end end
Version data entries
19 entries across 19 versions & 2 rubygems