Skip to content

Commit

Permalink
feat: replace kernel with URI for Ruby 3 compatibility
Browse files Browse the repository at this point in the history
In Ruby 2, Kernel.open worked for both local and remote files.
In Ruby 3, this was changed such that Kernel.open would only open local files.
URI.open became the prefered syntax for opening remote files.
ruby/open-uri@53862fa

Co-authored-by: Nate Perry <[email protected]>
  • Loading branch information
dezkowalski and ncperry committed Mar 6, 2024
1 parent 45bd7bc commit 9799436
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/qualtrics_api/response_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def file_url
def open(&block)
raise QualtricsAPI::FileNotReadyError, "Cannot open exported file because the file url is missing." if file_url.nil?

Kernel.open(file_url, **QualtricsAPI.connection(self).headers, &block)
URI.open(file_url, **QualtricsAPI.connection(self).headers, &block)
end
end
end
4 changes: 2 additions & 2 deletions spec/lib/response_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@

it "conforms to ruby 3 keyword-argument format" do
subject.instance_variable_set(:@file_url, "some_url")
expect(Kernel).to receive(:open) do |*args, **kwargs|
expect(URI).to receive(:open) do |*args, **kwargs|
expect(args).to eq ["some_url"]
expect(kwargs.class).to eq Faraday::Utils::Headers
end
Expand All @@ -128,7 +128,7 @@
end

it "opens the linked file with the file_url and qualtrics connection" do
expect(Kernel).to receive(:open).with("some_url", connection_headers)
expect(URI).to receive(:open).with("some_url", connection_headers)
subject.open
end
end
Expand Down

0 comments on commit 9799436

Please sign in to comment.