Module: Treebis::Test::TestPatch
- Included in:
- TestCase
- Defined in:
- lib/treebis.rb
Instance Method Summary collapse
Instance Method Details
#test_patch_fails ⇒ Object
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 |
# File 'lib/treebis.rb', line 1275 def test_patch_fails src = empty_tmpdir 'patch/evil' task.new do write "badly-formed-patch-file.diff", <<-P i am not a good patch P end.on(src).run tgt = empty_tmpdir 'patch/innocent' patch_task = task.new do from src apply 'badly-formed-patch-file.diff' end e = assert_raises(Treebis::Fail) do patch_task.on(tgt).run end assert_match(/Failed to run patch command/, e.) end |
#test_patch_hack ⇒ Object
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
# File 'lib/treebis.rb', line 1293 def test_patch_hack task.new { write "some-file.txt", <<-X i am the new content X }.on(src = empty_tmpdir('src')).run task.new { write "some-file.txt", <<-X never see me X }.on(tgt = empty_tmpdir('tgt')).run task.new { from src opts[:patch_hack] = true apply "some-file.txt.diff" }.on(tgt).run assert_equal( {"some-file.txt"=>"i am the new content\n"}, dir_as_hash(tgt) ) end |
#test_unexpected_string_from_patch ⇒ Object
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 |
# File 'lib/treebis.rb', line 1314 def test_unexpected_string_from_patch out, err, res = capture3 do task.new do pretty_puts_apply("i am another string", []) nil end.on(empty_tmpdir("blah")).run end assert_equal [nil, ""], [res, out] assert err.index("i am another string") end |