Skip to content

Commit 7bf915b

Browse files
author
Glyn Normington
committed
Reset internet availability check before each spec
Some specs run with WebMocks and mock no internet connection while other specs, notably integration tests, run and access the internet. Depending on the order of running of specs, an incorrect internet availability is cached in a DownloadCache class variable. Reset the cache before each spec. [#59391214]
1 parent 0b2613c commit 7bf915b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/java_buildpack/util/download_cache.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ def self.store_internet_availability(internet_up)
164164
internet_up
165165
end
166166

167+
def self.clear_internet_availability
168+
@@monitor.synchronize do
169+
@@internet_checked = false
170+
end
171+
end
172+
167173
def delete_file(filename)
168174
File.delete filename if File.exists? filename
169175
end

spec/spec_helper.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
require 'fileutils'
2929
require 'java_buildpack/diagnostics/common'
3030
require 'java_buildpack/diagnostics/logger_factory'
31+
require 'java_buildpack/util/download_cache'
3132

3233
RSpec.configure do |config|
3334
config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -41,6 +42,8 @@
4142
diagnostics_directory = File.join(tmpdir, JavaBuildpack::Diagnostics::DIAGNOSTICS_DIRECTORY)
4243
FileUtils.rm_rf diagnostics_directory
4344
JavaBuildpack::Diagnostics::LoggerFactory.create_logger tmpdir
45+
# Reset internet availability check before each test.
46+
JavaBuildpack::Util::DownloadCache.send :clear_internet_availability
4447
end
4548
config.after(:all) do
4649
$stderr = STDERR

0 commit comments

Comments
 (0)