summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/library/win32ole/fixtures/classes.rb11
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb15
-rw-r--r--spec/ruby/library/win32ole/win32ole/shared/ole_method.rb15
3 files changed, 9 insertions, 32 deletions
diff --git a/spec/ruby/library/win32ole/fixtures/classes.rb b/spec/ruby/library/win32ole/fixtures/classes.rb
index 830b1be0b5..cde47f7580 100644
--- a/spec/ruby/library/win32ole/fixtures/classes.rb
+++ b/spec/ruby/library/win32ole/fixtures/classes.rb
@@ -1,14 +1,17 @@
module WIN32OLESpecs
def self.new_ole(name)
- retried = false
+ tries = 0
begin
WIN32OLE.new(name)
rescue WIN32OLERuntimeError => e
- unless retried
- retried = true
+ if tries < 3
+ tries += 1
+ $stderr.puts "WIN32OLESpecs#new_ole retry (#{tries}): #{e.class}: #{e.message}"
+ sleep(2 ** tries)
retry
+ else
+ raise
end
- raise e
end
end
end
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 8b5b9c13ed..8a510519f2 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
@@ -5,20 +5,7 @@ platform_is :windows do
describe "WIN32OLE#ole_func_methods" do
before :each do
- # 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
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
end
after :each do
diff --git a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
index 9fdb5f2055..33268e0aa2 100644
--- a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
+++ b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
@@ -5,20 +5,7 @@ platform_is :windows do
describe :win32ole_ole_method, shared: true do
before :each do
- # 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_method retry (#{tries}): #{e.class}: #{e.message}"
- retry
- end
- end
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
end
after :each do