Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use URI.open: Needed for Ruby 3 #743

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/thor/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def apply(path, config = {})

contents = if is_uri
require "open-uri"
open(path, "Accept" => "application/x-thor-template", &:read)
URI.open(path, "Accept" => "application/x-thor-template", &:read)
else
open(path, &:read)
end
Expand Down
8 changes: 6 additions & 2 deletions spec/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,17 @@ def file

it "accepts a URL as the path" do
@file = "http://gist.github.com/103208.txt"
expect(runner).to receive(:open).with(@file, "Accept" => "application/x-thor-template").and_return(@template)
stub_request(:get, @file)

expect(runner).to receive(:apply).with(@file).and_return(@template)
action(:apply, @file)
end

it "accepts a secure URL as the path" do
@file = "https://gist.github.com/103208.txt"
expect(runner).to receive(:open).with(@file, "Accept" => "application/x-thor-template").and_return(@template)
stub_request(:get, @file)

expect(runner).to receive(:apply).with(@file).and_return(@template)
action(:apply, @file)
end

Expand Down