From d010e53be7c09e1fbfdf96f3d0e4a235d3cc74b8 Mon Sep 17 00:00:00 2001 From: Lauma Cirule Date: Fri, 4 Oct 2024 12:05:22 +0300 Subject: [PATCH 1/2] Refactor environment handling in web server spec Class variable access from top level gives RuntimeError --- spec/warbler/web_server_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/warbler/web_server_spec.rb b/spec/warbler/web_server_spec.rb index 8da8c1eb..7cfcd3b4 100644 --- a/spec/warbler/web_server_spec.rb +++ b/spec/warbler/web_server_spec.rb @@ -8,9 +8,9 @@ def self.reset_local_repository describe Warbler::WebServer::Artifact do - @@_env = ENV.to_h - - after(:all) { ENV.clear; ENV.update @@_env } + before(:all) do + @_env = ENV.to_h + end before do Warbler::WebServer::Artifact.reset_local_repository @@ -18,6 +18,8 @@ def self.reset_local_repository after(:all) do Warbler::WebServer::Artifact.reset_local_repository + ENV.clear + ENV.update @_env end let(:sample_artifact) do From ae578436359a14895d54a749b7975e2be78b96b2 Mon Sep 17 00:00:00 2001 From: Lauma Cirule Date: Fri, 4 Oct 2024 12:06:08 +0300 Subject: [PATCH 2/2] Update open-uri usage in web server --- lib/warbler/web_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/warbler/web_server.rb b/lib/warbler/web_server.rb index 5dce7078..d2ac03fa 100644 --- a/lib/warbler/web_server.rb +++ b/lib/warbler/web_server.rb @@ -20,7 +20,7 @@ def local_path FileUtils.mkdir_p File.dirname(cached_path) #:nocov: require 'open-uri' #:nocov: begin - open(download_url) do |stream| #:nocov: + URI.open(download_url) do |stream| #:nocov: File.open(cached_path, "wb") do |f| #:nocov: while buf = stream.read(4096) #:nocov: f << buf #:nocov: