Skip to content

Commit 4ce38c5

Browse files
author
Florian Heinle
committed
Use URI.open: Needed for Ruby 3
1 parent 34df888 commit 4ce38c5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/thor/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def apply(path, config = {})
219219

220220
contents = if is_uri
221221
require "open-uri"
222-
open(path, "Accept" => "application/x-thor-template", &:read)
222+
URI.open(path, "Accept" => "application/x-thor-template", &:read)
223223
else
224224
open(path, &:read)
225225
end

spec/actions_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,17 @@ def file
231231

232232
it "accepts a URL as the path" do
233233
@file = "http://gist.github.com/103208.txt"
234-
expect(runner).to receive(:open).with(@file, "Accept" => "application/x-thor-template").and_return(@template)
234+
stub_request(:get, @file)
235+
236+
expect(runner).to receive(:apply).with(@file).and_return(@template)
235237
action(:apply, @file)
236238
end
237239

238240
it "accepts a secure URL as the path" do
239241
@file = "https://gist.github.com/103208.txt"
240-
expect(runner).to receive(:open).with(@file, "Accept" => "application/x-thor-template").and_return(@template)
242+
stub_request(:get, @file)
243+
244+
expect(runner).to receive(:apply).with(@file).and_return(@template)
241245
action(:apply, @file)
242246
end
243247

0 commit comments

Comments
 (0)