aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorAdam Smith2017-09-27 00:17:47 -0700
committerAdam Smith2017-09-30 18:25:12 -0700
commit92311901c9d85e0e43147386535118b66ca718cd (patch)
treefc87fcca3515b415b94c001f8e9e6eac5d3c9d93 /Library/Homebrew/test
parenta1140f7b926ce7b87727a6cd105cbe2d788f3a4c (diff)
downloadbrew-92311901c9d85e0e43147386535118b66ca718cd.tar.bz2
add available languages to cask info command
add language tests for dsl add fixtures, tests for languages info output add extra lines
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/cask/cli/info_spec.rb32
-rw-r--r--Library/Homebrew/test/cask/dsl_spec.rb30
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-languages.rb9
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-languages.rb18
4 files changed, 89 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/cli/info_spec.rb b/Library/Homebrew/test/cask/cli/info_spec.rb
index aec7080de..7d6dfd76d 100644
--- a/Library/Homebrew/test/cask/cli/info_spec.rb
+++ b/Library/Homebrew/test/cask/cli/info_spec.rb
@@ -90,6 +90,38 @@ describe Hbc::CLI::Info, :cask do
EOS
end
+ it "should print languages if the Cask provided any" do
+ expect {
+ Hbc::CLI::Info.run("with-languages")
+ }.to output(<<-EOS.undent).to_stdout
+ with-languages: 1.2.3
+ http://example.com/local-caffeine
+ Not installed
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-languages.rb
+ ==> Name
+ None
+ ==> Languages
+ zh, en-US
+ ==> Artifacts
+ Caffeine.app (App)
+ EOS
+ end
+
+ it 'should not print "Languages" section divider if the languages block has no output' do
+ expect {
+ Hbc::CLI::Info.run("with-conditional-languages")
+ }.to output(<<-EOS.undent).to_stdout
+ with-conditional-languages: 1.2.3
+ http://example.com/local-caffeine
+ Not installed
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-languages.rb
+ ==> Name
+ None
+ ==> Artifacts
+ Caffeine.app (App)
+ EOS
+ end
+
describe "when no Cask is specified" do
it "raises an exception" do
expect {
diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb
index aec1e917f..c2a7b2367 100644
--- a/Library/Homebrew/test/cask/dsl_spec.rb
+++ b/Library/Homebrew/test/cask/dsl_spec.rb
@@ -177,6 +177,36 @@ describe Hbc::DSL, :cask do
expect(cask.call.sha256).to eq("xyz789")
expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip")
end
+
+ it "returns empty array if no languages specified" do
+ cask = lambda do
+ Hbc::Cask.new("cask-with-apps") do
+ url "https://example.org/file.zip"
+ end
+ end
+
+ expect(cask.call.languages).to be_empty
+ end
+
+ it "returns an array of available languages" do
+ cask = lambda do
+ Hbc::Cask.new("cask-with-apps") do
+ language "zh" do
+ sha256 "abc123"
+ "zh-CN"
+ end
+
+ language "en-US", default: true do
+ sha256 "xyz789"
+ "en-US"
+ end
+
+ url "https://example.org/file.zip"
+ end
+ end
+
+ expect(cask.call.languages).to eq(["zh", "en-US"])
+ end
end
describe "app stanza" do
diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-languages.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-languages.rb
new file mode 100644
index 000000000..bf3b9b1c4
--- /dev/null
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-languages.rb
@@ -0,0 +1,9 @@
+cask 'with-conditional-languages' do
+ version '1.2.3'
+ sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
+
+ url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
+ homepage 'http://example.com/local-caffeine'
+
+ app 'Caffeine.app'
+end
diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-languages.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-languages.rb
new file mode 100644
index 000000000..90ff63846
--- /dev/null
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-languages.rb
@@ -0,0 +1,18 @@
+cask 'with-languages' do
+ version '1.2.3'
+
+ language "zh" do
+ sha256 "abc123"
+ "zh-CN"
+ end
+
+ language "en-US", default: true do
+ sha256 "xyz789"
+ "en-US"
+ end
+
+ url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
+ homepage 'http://example.com/local-caffeine'
+
+ app 'Caffeine.app'
+end