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

View File

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