diff --git a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb index 8a510519f2..8b5b9c13ed 100644 --- a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb @@ -5,7 +5,20 @@ platform_is :windows do describe "WIN32OLE#ole_func_methods" do before :each do - @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + # This part is unstable, so retrying 3 times. + tries = 0 + begin + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + rescue WIN32OLERuntimeError => e + # WIN32OLERuntimeError: failed to create WIN32OLE object from `InternetExplorer.Application' + # HRESULT error code:0x800704a6 + # A system shutdown has already been scheduled. + if tries < 3 + tries += 1 + $stderr.puts "WIN32OLE#ole_func_methods retry (#{tries}): #{e.class}: #{e.message}" + retry + end + end end after :each do