Fix code style and add tests
This commit is contained in:
parent
f5765a73da
commit
1fc1c82aed
@ -99,11 +99,11 @@ module Cask
|
|||||||
description = key ? "#{stanza} #{key.inspect}" : stanza.to_s
|
description = key ? "#{stanza} #{key.inspect}" : stanza.to_s
|
||||||
|
|
||||||
# backward-compatible string value
|
# backward-compatible string value
|
||||||
if arguments.is_a?(String)
|
arguments = if arguments.is_a?(String)
|
||||||
arguments = { executable: arguments }
|
{ executable: arguments }
|
||||||
else
|
else
|
||||||
# Avoid mutating the original argument
|
# Avoid mutating the original argument
|
||||||
arguments = arguments.dup
|
arguments.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
# key sanity
|
# key sanity
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
describe Cask::Artifact::AbstractArtifact, :cask do
|
||||||
|
describe ".read_script_arguments" do
|
||||||
|
it "accepts a string, and uses it as the executable" do
|
||||||
|
arguments = "something"
|
||||||
|
stanza = :installer
|
||||||
|
|
||||||
|
expect(described_class.read_script_arguments(arguments, stanza)).to eq(["something", {}])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "accepts a hash with an executable" do
|
||||||
|
arguments = { executable: "something" }
|
||||||
|
stanza = :installer
|
||||||
|
|
||||||
|
expect(described_class.read_script_arguments(arguments, stanza)).to eq(["something", {}])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not mutate the arguments in place" do
|
||||||
|
arguments = { executable: "something", foo: "bar" }
|
||||||
|
clone = arguments.dup
|
||||||
|
stanza = :installer
|
||||||
|
|
||||||
|
described_class.read_script_arguments(arguments, stanza)
|
||||||
|
|
||||||
|
expect(arguments).to eq(clone)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user