Module: Treebis::Test::TestTempdirAndTasksAndCopy
- Included in:
- TestCase
- Defined in:
- lib/treebis.rb
Instance Method Summary collapse
- #test_can_open_same_name_in_different_task_sets ⇒ Object
- #test_cant_reopen_tasks ⇒ Object
- #test_copy_one_file ⇒ Object
- #test_copy_one_file_a_bunch_of_tmpdir_crap ⇒ Object
- #test_copy_one_file_almost_nothing_exist ⇒ Object
- #test_copy_one_file_nothing_exist ⇒ Object
Instance Method Details
#test_can_open_same_name_in_different_task_sets ⇒ Object
1425 1426 1427 1428 |
# File 'lib/treebis.rb', line 1425 def test_can_open_same_name_in_different_task_sets Treebis::TaskSet.new.task(:same){} Treebis::TaskSet.new.task(:same){} end |
#test_cant_reopen_tasks ⇒ Object
1416 1417 1418 1419 1420 1421 1422 1423 1424 |
# File 'lib/treebis.rb', line 1416 def test_cant_reopen_tasks tasks = Treebis::TaskSet.new tasks.task(:same){} e = assert_raises(RuntimeError) do tasks.task(:same){} end exp = "can't reopen task: :same" assert_equal(exp, e.) end |
#test_copy_one_file ⇒ Object
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 |
# File 'lib/treebis.rb', line 1461 def test_copy_one_file the_tmpdir = tmpdir # doc start content = "i am the content of\na file called baz.txt\n" File.open(the_tmpdir+'/baz.txt','w+') do |fh| fh.puts(content) end tasks = Treebis::TaskSet.new tasks.task(:default) do mkdir_p_unless_exists # makes output dir referred to in on() below from the_tmpdir # the source directory copy('./baz.txt') end tasks[:default].on(the_tmpdir+'/out-dir/').run() output = File.read(the_tmpdir+'/out-dir/baz.txt') # doc stop assert_equal(content, output) end |
#test_copy_one_file_a_bunch_of_tmpdir_crap ⇒ Object
1452 1453 1454 1455 1456 1457 1458 1459 1460 |
# File 'lib/treebis.rb', line 1452 def test_copy_one_file_a_bunch_of_tmpdir_crap out_dir = tmpdir+'/out-dir' src_file = tmpdir+'/baz.txt' file_utils.remove_entry_secure(out_dir) if File.exist?(out_dir) file_utils.remove_entry_secure(src_file) if File.exist?(src_file) self.class.instance_variable_set('@tmpdir',nil) tmpdir # gets to a hard to reach line test_copy_one_file end |
#test_copy_one_file_almost_nothing_exist ⇒ Object
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 |
# File 'lib/treebis.rb', line 1438 def test_copy_one_file_almost_nothing_exist out_dir = tmpdir+'/out-dir' src_file = tmpdir+'/baz.txt' per_file = self.class.dotfile_path file_utils.remove_entry_secure(out_dir) if File.exist?(out_dir) file_utils.remove_entry_secure(src_file) if File.exist?(src_file) if File.exist?(per_file) struct = JSON.parse(File.read(per_file)) if File.exist?(struct["tmpdir"]) file_utils.remove_entry_secure(struct["tmpdir"]) end end test_copy_one_file end |
#test_copy_one_file_nothing_exist ⇒ Object
1429 1430 1431 1432 1433 1434 1435 1436 1437 |
# File 'lib/treebis.rb', line 1429 def test_copy_one_file_nothing_exist out_dir = tmpdir+'/out-dir' src_file = tmpdir+'/baz.txt' per_file = self.class.dotfile_path file_utils.remove_entry_secure(out_dir) if File.exist?(out_dir) file_utils.remove_entry_secure(src_file) if File.exist?(src_file) file_utils.remove_entry_secure(per_file) if File.exist?(per_file) test_copy_one_file end |