Module: Treebis::Test::TestFileUtilsProxy
- Included in:
- TestCase
- Defined in:
- lib/treebis.rb
Instance Method Summary collapse
- #test_cp_not_pretty ⇒ Object
- #test_custom_fileutils_implementation ⇒ Object
- #test_patch_fileutils ⇒ Object
- #test_pretty_puts_cp_unexpected_output ⇒ Object
Instance Method Details
#test_cp_not_pretty ⇒ Object
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
# File 'lib/treebis.rb', line 1197 def test_cp_not_pretty src_dir = empty_tmpdir('foo') tgt_dir = empty_tmpdir('bar') task.new{ mkdir_p write 'some-file.txt', <<-X i am some text X }.on(src_dir).run task.new { from(src_dir) report_action :notice, "the below is not supposed to be pretty" file_utils.not_pretty! copy 'some-file.txt' mkdir_p 'emptoz' file_utils.pretty! report_action :notice, "the above was not pretty" }.on(tgt_dir).run act = dir_as_hash tgt_dir exp = { "some-file.txt"=>"i am some text\n", "emptoz" => {} } assert_equal(exp, act) end |
#test_custom_fileutils_implementation ⇒ Object
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 |
# File 'lib/treebis.rb', line 1240 def test_custom_fileutils_implementation task = self.task.new do from 'not there' copy 'doesnt even exist' end fu = Object.new class << fu def prefix; '_____' end def ui; $stdout end end hi_there = false class << fu; self end.send(:define_method, :cp) do |*blah| hi_there = blah end task.file_utils = fu task.on('doesnt exist here').run exp = ["not there/doesnt even exist", "doesnt exist here/doesnt even exist"] act = hi_there[0..1] assert_equal exp, act end |
#test_patch_fileutils ⇒ Object
1225 1226 1227 1228 1229 1230 1231 1232 1233 |
# File 'lib/treebis.rb', line 1225 def test_patch_fileutils tmpdir = empty_tmpdir('oilspill') out, err = capture3 do file_utils.remove_entry_secure tmpdir+'/not-there' file_utils.mkdir_p tmpdir, :verbose => true end assert_match(/didn't exist.+not-there/, err) assert_match(/mkdir_p.+exists.+oilspill/, err) end |
#test_pretty_puts_cp_unexpected_output ⇒ Object
1234 1235 1236 1237 1238 1239 |
# File 'lib/treebis.rb', line 1234 def test_pretty_puts_cp_unexpected_output e = assert_raises(RuntimeError) do file_utils.send(:pretty_puts_cp, false, '', '') end assert_match(/unexpected out/, e.) end |