
- Part of trying to reduce the number of `Excludes:` we have in our RuboCop configs. - The fixes here all seemed reasonable, with some minimal tweaks for line length and less floatiness. Apart from `test/dev-cmd/bottle_spec.rb` where RuboCop wanted to do some ridiculously floaty indentation and there wasn't an obvious alternative place to break the lines, so I opted for in-line disables instead.
61 lines
1.6 KiB
Ruby
61 lines
1.6 KiB
Ruby
# typed: false
|
|
# frozen_string_literal: true
|
|
|
|
require "download_strategy"
|
|
|
|
describe CurlPostDownloadStrategy do
|
|
subject(:strategy) { described_class.new(url, name, version, **specs) }
|
|
|
|
let(:name) { "foo" }
|
|
let(:url) { "https://example.com/foo.tar.gz" }
|
|
let(:version) { "1.2.3" }
|
|
let(:specs) { {} }
|
|
|
|
describe "#fetch" do
|
|
before do
|
|
strategy.temporary_path.dirname.mkpath
|
|
FileUtils.touch strategy.temporary_path
|
|
end
|
|
|
|
context "with :using and :data specified" do
|
|
let(:specs) {
|
|
{
|
|
using: :post,
|
|
data: {
|
|
form: "data",
|
|
is: "good",
|
|
},
|
|
}
|
|
}
|
|
|
|
it "adds the appropriate curl args" do
|
|
expect(strategy).to receive(:system_command)
|
|
.with(
|
|
/curl/,
|
|
hash_including(args: array_including_cons("-d", "form=data").and(array_including_cons("-d", "is=good"))),
|
|
)
|
|
.at_least(:once)
|
|
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
|
|
|
strategy.fetch
|
|
end
|
|
end
|
|
|
|
context "with :using but no :data" do
|
|
let(:specs) { { using: :post } }
|
|
|
|
it "adds the appropriate curl args" do
|
|
expect(strategy).to receive(:system_command)
|
|
.with(
|
|
/curl/,
|
|
hash_including(args: array_including_cons("-X", "POST")),
|
|
)
|
|
.at_least(:once)
|
|
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
|
|
|
strategy.fetch
|
|
end
|
|
end
|
|
end
|
|
end
|