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

- old
+ new

@@ -33,46 +33,50 @@ require 'test/unit' require 'tmpdir' require 'ucf' # Classes to test managed entries. -class ManagedUCF < UCF::Container +class ManagedUCF < UCF::File private_class_method :new def initialize(filename) super(filename) - register_managed_entry(ZipContainer::ManagedDirectory.new("src", true)) + register_managed_entry(ZipContainer::ManagedDirectory.new("src", + :required => true)) register_managed_entry(ZipContainer::ManagedDirectory.new("test")) register_managed_entry(ZipContainer::ManagedDirectory.new("lib")) - register_managed_entry(ZipContainer::ManagedFile.new("index.html", true)) + register_managed_entry(ZipContainer::ManagedFile.new("index.html", + :required => true)) end end -class ExampleUCF < UCF::Container +class ExampleUCF < UCF::File private_class_method :new def initialize(filename) super(filename) - register_managed_entry(ZipContainer::ManagedDirectory.new("dir", true)) - register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt", true)) + register_managed_entry(ZipContainer::ManagedDirectory.new("dir", + :required => true)) + register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt", + :required => true)) end end -class ExampleUCF2 < UCF::Container +class ExampleUCF2 < UCF::File 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", - true, valid)) + :required => true, :validation_proc => valid)) end end class TestManagedEntries < Test::Unit::TestCase @@ -109,11 +113,11 @@ def test_create_standard_container Dir.mktmpdir do |dir| filename = File.join(dir, "test.ucf") assert_nothing_raised do - UCF::Container.create(filename) do |c| + UCF::File.create(filename) do |c| c.mkdir("META-INF") assert(c.file.exists?("META-INF")) %w(container.xml manifest.xml).each do |file| full_path = "META-INF/#{file}" @@ -122,11 +126,11 @@ end end end assert_nothing_raised(ZipContainer::MalformedContainerError) do - UCF::Container.verify!(filename) + UCF::File.verify!(filename) end end end # Check that a ManagedUCF does not verify immediately after creation. @@ -174,11 +178,11 @@ # with the correct contents. def test_create_subclassed_container_with_content_verification Dir.mktmpdir do |dir| filename = File.join(dir, "test.ucf") - assert_nothing_raised do + #assert_nothing_raised do ExampleUCF2.create(filename) do |c| assert_raises(ZipContainer::MalformedContainerError) do c.verify! end @@ -196,10 +200,10 @@ assert_nothing_raised(ZipContainer::MalformedContainerError) do c.verify! end end - end + #end assert(ExampleUCF2.verify(filename)) assert_nothing_raised(ZipContainer::MalformedContainerError) do ExampleUCF2.verify!(filename) end