Module: Treebis::Test::TestAntecedents

Included in:
TestCase
Defined in:
lib/treebis.rb

Instance Method Summary collapse

Instance Method Details

#setup_antecedentsObject



977
978
979
980
981
982
983
984
985
986
# File 'lib/treebis.rb', line 977

def setup_antecedents
  src = empty_tmpdir('sourceis')
  task.new do
    mkdir_p "foo/bar/baz"
    write "foo/bar/baz/alpha.txt", 'x'
    write "foo/bar/beta.txt", 'x'
    write "foo/gamma.txt", 'x'
  end.on(src).run
  src
end

#test_antecedentsObject



987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
# File 'lib/treebis.rb', line 987

def test_antecedents
  src = setup_antecedents
  tt = task.new do
    from src
    mkdir_p "foo/bar/baz"
    copy "foo/bar/baz/alpha.txt"
    copy "foo/bar/beta.txt"
    copy "foo/gamma.txt"
  end
  tgt = empty_tmpdir('targetis')
  bb, cc, aa = capture3{ tt.on(tgt).run }
  assert_equal [nil, ''], [aa,bb]
  penu, last = cc.split("\n")[-2..-1]
  assert penu.index("...bar/beta.txt foo/bar/beta.txt")
  assert last.index("...eis/foo/gamma.txt foo/gamma.txt")
end

#test_antecedents_rawObject



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
# File 'lib/treebis.rb', line 1004

def test_antecedents_raw
  fu = file_utils
  src = setup_antecedents
  tgt = empty_tmpdir('targetis')
  these = %w(    foo/bar/baz/alpha.txt
                 foo/bar/beta.txt
                 foo/gamma.txt          )
  fu.pretty!
  out, err = capture3 do
    fu.mkdir_p File.join(tgt,'foo/bar/baz')
    these.each do |foo|
      from, to = File.join(src,foo), File.join(tgt,foo)
      fu.cp from, to
    end
  end
  assert_equal '', out
  penu, last = err.split("\n")[-2..-1]
  assert penu.index(' ...bar/beta.txt ...bar/beta.txt')
  assert last.index('...eis/foo/gamma.txt ...tis/foo/gamma.txt')
end