Stub MacOS.languages instead of setting HOMEBREW_LANGUAGES.

This commit is contained in:
Markus Reiter 2016-09-21 22:19:04 +02:00
parent 1e86c7d3ec
commit b703c81ca6
2 changed files with 5 additions and 9 deletions

View File

@ -123,10 +123,6 @@ describe Hbc::DSL do
end end
describe "language stanza" do describe "language stanza" do
after(:each) do
ENV["HOMEBREW_LANGUAGES"] = nil
end
it "allows multilingual casks" do it "allows multilingual casks" do
cask = lambda { cask = lambda {
Hbc::Cask.new("cask-with-apps") do Hbc::Cask.new("cask-with-apps") do
@ -144,13 +140,13 @@ describe Hbc::DSL do
end end
} }
ENV["HOMEBREW_LANGUAGES"] = "FIRST_LANGUAGE" MacOS.stubs(languages: ["FIRST_LANGUAGE"])
cask.call.language.must_equal :first cask.call.language.must_equal :first
ENV["HOMEBREW_LANGUAGES"] = "SECOND_LANGUAGE" MacOS.stubs(languages: ["SECOND_LANGUAGE"])
cask.call.language.must_equal :second cask.call.language.must_equal :second
ENV["HOMEBREW_LANGUAGES"] = "THIRD_LANGUAGE" MacOS.stubs(languages: ["THIRD_LANGUAGE"])
cask.call.language.must_equal :default cask.call.language.must_equal :default
end end
end end

View File

@ -42,10 +42,10 @@ module OS
end end
def languages def languages
if ENV["HOMEBREW_LANGUAGES"] @languages ||= if ENV["HOMEBREW_LANGUAGES"]
ENV["HOMEBREW_LANGUAGES"].split(",") ENV["HOMEBREW_LANGUAGES"].split(",")
else else
@languages ||= Utils.popen_read("defaults", "read", ".GlobalPreferences", "AppleLanguages").scan(/[^ \n"(),]+/) Utils.popen_read("defaults", "read", ".GlobalPreferences", "AppleLanguages").scan(/[^ \n"(),]+/)
end end
end end