test/tc_managed_entries.rb in ucf-1.0.0 vs test/tc_managed_entries.rb in ucf-1.1.0

- old
+ new

@@ -77,10 +77,25 @@ :required => true, :validation_proc => valid)) end end +class ExampleUCFDir < UCF::Dir + + private_class_method :new + + def initialize(filename) + super(filename) + + valid = Proc.new { |contents| contents.match(/[Hh]ello/) } + + register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt", + :required => true, :validation_proc => valid)) + end + +end + class TestManagedEntries < Test::Unit::TestCase # Check that the example UCF document does not validate as a ManagedUCF. def test_fail_verification refute(ManagedUCF.verify($ucf_example)) @@ -103,9 +118,18 @@ def test_pass_verification_2 assert(ExampleUCF2.verify($ucf_example)) assert_nothing_raised(ZipContainer::MalformedContainerError) do ExampleUCF2.verify!($ucf_example) + end + end + + # Check that the example UCF directory validates. + def test_pass_verification_dir + assert(ExampleUCFDir.verify($dir_mngd)) + + assert_nothing_raised(ZipContainer::MalformedContainerError) do + ExampleUCFDir.verify!($dir_mngd) end end # Check that a standard UCF Container can be created and things within it # are verified correctly.