java_requirement: set cask attribute
Set `@cask` attribute for JavaRequirement, which is used by
`brew info` to track cask requirement for formulae and
`brew bundle dump` to sort the formulae and casks.
Before:
```
$ brew info --json languagetool | jq '.[0].requirements'
[
{
"name": "java",
"cask": null,
"download": null
}
]
$ brew cask install adoptopenjdk; brew install languagetool
$ brew bundle dump
brew "languagetool"
cask "adoptopenjdk"
```
After:
```
$ brew info --json languagetool | jq '.[0].requirements'
[
{
"name": "java",
"cask": "adoptopenjdk",
"download": null
}
]
$ brew cask install adoptopenjdk; brew install languagetool
$ brew bundle dump
cask "adoptopenjdk"
brew "languagetool"
```
Also added relevant test cases.
This commit is contained in:
parent
c95cf90e32
commit
2bd9b2774d
@ -30,6 +30,7 @@ class JavaRequirement < Requirement
|
||||
def initialize(tags = [])
|
||||
@version = tags.shift if /^\d/ =~ tags.first
|
||||
super(tags)
|
||||
@cask = suggestion.token
|
||||
end
|
||||
|
||||
def message
|
||||
|
||||
@ -105,4 +105,25 @@ describe JavaRequirement do
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user