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", " i am not a good patch\n P\n end.on(src).run\n\n tgt = empty_tmpdir 'patch/innocent'\n patch_task = task.new do\n from src\n apply 'badly-formed-patch-file.diff'\n end\n e = assert_raises(Treebis::Fail) do\n patch_task.on(tgt).run\n end\n assert_match(/Failed to run patch command/, e.message)\nend\n" |
#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", " i am the new content\n X\n }.on(src = empty_tmpdir('src')).run\n task.new {\n write \"some-file.txt\", <<-X\n never see me\n X\n }.on(tgt = empty_tmpdir('tgt')).run\n task.new {\n from src\n opts[:patch_hack] = true\n apply \"some-file.txt.diff\"\n }.on(tgt).run\n assert_equal(\n {\"some-file.txt\"=>\"i am the new content\\n\"},\n dir_as_hash(tgt)\n )\nend\n" |
#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 |