test/test_property_set.rb in ruby-ole-1.2.6 vs test/test_property_set.rb in ruby-ole-1.2.7

- old
+ new

@@ -1,14 +1,13 @@ #! /usr/bin/ruby $: << File.dirname(__FILE__) + '/../lib' require 'test/unit' -require 'ole/storage' -require 'ole/property_set' +require 'ole/types/property_set' -class TestTypes < Test::Unit::TestCase +class TestPropertySet < Test::Unit::TestCase include Ole::Types def setup @io = open File.dirname(__FILE__) + '/test_SummaryInformation', 'rb' end @@ -23,18 +22,19 @@ assert_equal 1, propset.sections.length section = propset.sections.first assert_equal 14, section.length assert_equal 'f29f85e0-4ff9-1068-ab91-08002b27b3d9', section.guid.format assert_equal PropertySet::FMTID_SummaryInformation, section.guid - assert_equal 'Charles Lowe', section.properties.assoc(4).last - # new named support - assert_equal 'Charles Lowe', section.doc_author - end - - def test_ole_storage_integration - Ole::Storage.open File.dirname(__FILE__) + '/test.doc', 'rb' do |ole| - assert_equal 'Charles Lowe', ole.summary_info.doc_author - assert_equal 'Title', ole.summary_info.doc_title - end + assert_equal 'Charles Lowe', section.to_a.assoc(4).last + assert_equal 'Charles Lowe', propset.doc_author + assert_equal 'Charles Lowe', propset.to_h[:doc_author] + + # knows the difference between existent and non-existent properties + assert_raise(NoMethodError) { propset.non_existent_key } + assert_raise(NotImplementedError) { propset.doc_author = 'New Author'} + assert_raise(NoMethodError) { propset.non_existent_key = 'Value'} + + # a valid property that has no value in this property set + assert_equal nil, propset.security end end