Merge pull request #6218 from xu-cheng/java_requirement

java_requirement: set cask attribute
This commit is contained in:
Mike McQuaid 2019-06-10 08:45:56 +01:00 committed by GitHub
commit 8529cf6529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -30,6 +30,7 @@ class JavaRequirement < Requirement
def initialize(tags = []) def initialize(tags = [])
@version = tags.shift if /^\d/ =~ tags.first @version = tags.shift if /^\d/ =~ tags.first
super(tags) super(tags)
@cask = suggestion.token
end end
def message def message

View File

@ -105,4 +105,25 @@ describe JavaRequirement do
end end
end end
end end
describe "#suggestion" do
context "without specific version" do
its(:suggestion) { is_expected.to match(/brew cask install adoptopenjdk/) }
its(:cask) { is_expected.to eq("adoptopenjdk") }
end
context "with version 1.8" do
subject { described_class.new(%w[1.8]) }
its(:suggestion) { is_expected.to match(%r{brew cask install homebrew/cask-versions/adoptopenjdk8}) }
its(:cask) { is_expected.to eq("homebrew/cask-versions/adoptopenjdk8") }
end
context "with version 1.8+" do
subject { described_class.new(%w[1.8+]) }
its(:suggestion) { is_expected.to match(/brew cask install adoptopenjdk/) }
its(:cask) { is_expected.to eq("adoptopenjdk") }
end
end
end end