aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMarkus Reiter2017-08-08 18:10:13 +0200
committerMarkus Reiter2017-08-08 18:10:13 +0200
commitae4bafdb365cfa380d129b0a03bd99a1e4d960a4 (patch)
treeab63c314bed39e41dfe47273902ca14c15515c23 /Library/Homebrew/test
parentb6b8e8863fe70fbdfd0758dd72127de0a96e329f (diff)
downloadbrew-ae4bafdb365cfa380d129b0a03bd99a1e4d960a4.tar.bz2
Simplify CurlDownloadStrategy.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/cask/download_strategy_spec.rb23
-rw-r--r--Library/Homebrew/test/cask/dsl/appcast_spec.rb11
2 files changed, 21 insertions, 13 deletions
diff --git a/Library/Homebrew/test/cask/download_strategy_spec.rb b/Library/Homebrew/test/cask/download_strategy_spec.rb
index 0c18f56b5..60d101bdb 100644
--- a/Library/Homebrew/test/cask/download_strategy_spec.rb
+++ b/Library/Homebrew/test/cask/download_strategy_spec.rb
@@ -27,8 +27,11 @@ describe "download strategies", :cask do
expect(downloader).to have_received(:curl).with(
cask.url.to_s,
- "-C", 0,
- "-o", kind_of(Pathname)
+ "--location",
+ "--remote-time",
+ "--continue-at", "-",
+ "--output", kind_of(Pathname),
+ user_agent: :default
)
end
@@ -36,25 +39,25 @@ describe "download strategies", :cask do
let(:url_options) { { user_agent: "Mozilla/25.0.1" } }
it "adds the appropriate curl args" do
- curl_args = []
- allow(downloader).to receive(:curl) { |*args| curl_args = args }
+ expect(downloader).to receive(:safe_system) { |*args|
+ expect(args.each_cons(2)).to include(["--user-agent", "Mozilla/25.0.1"])
+ }
downloader.fetch
-
- expect(curl_args.each_cons(2)).to include(["-A", "Mozilla/25.0.1"])
end
end
context "with a generalized fake user agent" do
+ alias_matcher :a_string_matching, :match
+
let(:url_options) { { user_agent: :fake } }
it "adds the appropriate curl args" do
- curl_args = []
- allow(downloader).to receive(:curl) { |*args| curl_args = args }
+ expect(downloader).to receive(:safe_system) { |*args|
+ expect(args.each_cons(2).to_a).to include(["--user-agent", a_string_matching(/Mozilla.*Mac OS X 10.*AppleWebKit/)])
+ }
downloader.fetch
-
- expect(curl_args.each_cons(2)).to include(["-A", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10) https://caskroom.github.io"])
end
end
diff --git a/Library/Homebrew/test/cask/dsl/appcast_spec.rb b/Library/Homebrew/test/cask/dsl/appcast_spec.rb
index b8903b1be..ccc6a4633 100644
--- a/Library/Homebrew/test/cask/dsl/appcast_spec.rb
+++ b/Library/Homebrew/test/cask/dsl/appcast_spec.rb
@@ -33,13 +33,18 @@ describe Hbc::DSL::Appcast do
describe "#calculate_checkpoint" do
before do
- expect(Hbc::SystemCommand).to receive(:run).with(*cmd_args).and_return(cmd_result)
+ expect(Hbc::SystemCommand).to receive(:run) do |executable, **options|
+ expect(executable).to eq "/usr/bin/curl"
+ expect(options[:args]).to include(*cmd_args)
+ expect(options[:print_stderr]).to be false
+ cmd_result
+ end
allow(cmd_result).to receive(:success?).and_return(cmd_success)
allow(cmd_result).to receive(:stdout).and_return(cmd_stdout)
end
context "when server returns a successful HTTP status" do
- let(:cmd_args) { ["/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", Hbc::URL::FAKE_USER_AGENT, "--fail", uri], print_stderr: false] }
+ let(:cmd_args) { [HOMEBREW_USER_AGENT_FAKE_SAFARI, "--compressed", "--location", "--fail", uri] }
let(:cmd_result) { double("Hbc::SystemCommand::Result") }
let(:cmd_success) { true }
let(:cmd_stdout) { "hello world" }
@@ -56,7 +61,7 @@ describe Hbc::DSL::Appcast do
end
context "when server returns a non-successful HTTP status" do
- let(:cmd_args) { ["/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", Hbc::URL::FAKE_USER_AGENT, "--fail", uri], print_stderr: false] }
+ let(:cmd_args) { [HOMEBREW_USER_AGENT_FAKE_SAFARI, "--compressed", "--location", "--fail", uri] }
let(:cmd_result) { double("Hbc::SystemCommand::Result") }
let(:cmd_success) { false }
let(:cmd_stdout) { "some error message from the server" }