ruby-changes:48544
From: suke <ko1@a...>
Date: Sun, 5 Nov 2017 10:02:10 +0900 (JST)
Subject: [ruby-changes:48544] suke:r60659 (trunk): ext/win32ole/lib/win32ole.rb (metods): rescue WIN32OLEQueryInterfaceError.
suke 2017-11-05 10:02:04 +0900 (Sun, 05 Nov 2017) New Revision: 60659 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60659 Log: ext/win32ole/lib/win32ole.rb (metods): rescue WIN32OLEQueryInterfaceError. test/win32ole/test_win32ole.rb: add test for WIN32OLE#methods Modified files: trunk/ext/win32ole/lib/win32ole.rb trunk/test/win32ole/test_win32ole.rb Index: ext/win32ole/lib/win32ole.rb =================================================================== --- ext/win32ole/lib/win32ole.rb (revision 60658) +++ ext/win32ole/lib/win32ole.rb (revision 60659) @@ -19,7 +19,15 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/lib/win32ole.rb#L19 # #=> Did you mean? Add # def methods(*args) - super + ole_methods.map(&:name) + super + ole_methods_safely.map(&:name) + end + + private + + def ole_methods_safely + ole_methods + rescue WIN32OLEQueryInterfaceError + [] end end end Index: test/win32ole/test_win32ole.rb =================================================================== --- test/win32ole/test_win32ole.rb (revision 60658) +++ test/win32ole/test_win32ole.rb (revision 60659) @@ -69,7 +69,12 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L69 mnames = methods.collect {|m| m.name } - assert(mnames.include?("Add")) + assert_include(mnames, 'Add') + end + + def test_methods + methods = @dict1.methods + assert_include(methods, 'Add') end def test_ole_func_methods @@ -77,7 +82,7 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L82 mnames = methods.collect {|m| m.name } - assert(mnames.include?("Add")) + assert_include(mnames, 'Add') end def test_ole_put_methods @@ -85,7 +90,7 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L90 mnames = methods.collect {|m| m.name } - assert(mnames.include?("CompareMode")) + assert_include(mnames, 'CompareMode') end def test_ole_get_methods @@ -93,7 +98,7 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L98 mnames = methods.collect {|m| m.name } - assert(mnames.include?("Count")) + assert_include(mnames, 'Count') end def test_ole_mehtod_help -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/