aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-09 04:15:57 +0100
committerMarkus Reiter2017-02-10 17:19:19 +0100
commita616fab5bf84d9e2a07610666cf148444c04b3c4 (patch)
tree10b940f2301ddcb4d998dd1e5c7686543a1ee56d /Library/Homebrew
parent6154182b13642de41125403d3be9959814d0afc3 (diff)
downloadbrew-a616fab5bf84d9e2a07610666cf148444c04b3c4.tar.bz2
Convert cask test to spec.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cask/spec/cask/cask_spec.rb69
-rw-r--r--Library/Homebrew/cask/test/cask_test.rb71
2 files changed, 69 insertions, 71 deletions
diff --git a/Library/Homebrew/cask/spec/cask/cask_spec.rb b/Library/Homebrew/cask/spec/cask/cask_spec.rb
index d470c6ec3..32f3d8258 100644
--- a/Library/Homebrew/cask/spec/cask/cask_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cask_spec.rb
@@ -20,4 +20,73 @@ describe Hbc::Cask do
end
end
end
+
+ describe "load" do
+ let(:hbc_relative_tap_path) { "../../Taps/caskroom/homebrew-cask" }
+
+ it "returns an instance of the Cask for the given token" do
+ c = Hbc.load("adium")
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("adium")
+ end
+
+ it "returns an instance of the Cask from a specific file location" do
+ location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
+ c = Hbc.load(location)
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("dia")
+ end
+
+ it "returns an instance of the Cask from a url" do
+ url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
+ c = shutup do
+ Hbc.load(url)
+ end
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("dia")
+ end
+
+ it "raises an error when failing to download a Cask from a url" do
+ expect {
+ url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb")
+ shutup do
+ Hbc.load(url)
+ end
+ }.to raise_error(Hbc::CaskUnavailableError)
+ end
+
+ it "returns an instance of the Cask from a relative file location" do
+ c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb")
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("bbedit")
+ end
+
+ it "uses exact match when loading by token" do
+ expect(Hbc.load("test-opera").token).to eq("test-opera")
+ expect(Hbc.load("test-opera-mail").token).to eq("test-opera-mail")
+ end
+
+ it "raises an error when attempting to load a Cask that doesn't exist" do
+ expect {
+ Hbc.load("notacask")
+ }.to raise_error(Hbc::CaskUnavailableError)
+ end
+ end
+
+ describe "all_tokens" do
+ it "returns a token for every Cask" do
+ all_cask_tokens = Hbc.all_tokens
+ expect(all_cask_tokens.count).to be > 20
+ all_cask_tokens.each { |token| expect(token).to be_kind_of(String) }
+ end
+ end
+
+ describe "metadata" do
+ it "proposes a versioned metadata directory name for each instance" do
+ cask_token = "adium"
+ c = Hbc.load(cask_token)
+ metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version)
+ expect(c.metadata_versioned_container_path.to_s).to eq(metadata_path.to_s)
+ end
+ end
end
diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb
deleted file mode 100644
index d3abda274..000000000
--- a/Library/Homebrew/cask/test/cask_test.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require "test_helper"
-
-describe "Cask" do
- hbc_relative_tap_path = "../../Taps/caskroom/homebrew-cask"
- describe "load" do
- it "returns an instance of the Cask for the given token" do
- c = Hbc.load("adium")
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("adium")
- end
-
- it "returns an instance of the Cask from a specific file location" do
- location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
- c = Hbc.load(location)
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("dia")
- end
-
- it "returns an instance of the Cask from a url" do
- url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
- c = shutup do
- Hbc.load(url)
- end
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("dia")
- end
-
- it "raises an error when failing to download a Cask from a url" do
- lambda {
- url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb")
- shutup do
- Hbc.load(url)
- end
- }.must_raise(Hbc::CaskUnavailableError)
- end
-
- it "returns an instance of the Cask from a relative file location" do
- c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb")
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("bbedit")
- end
-
- it "uses exact match when loading by token" do
- Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera.rb").token.must_equal("test-opera")
- Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera-mail.rb").token.must_equal("test-opera-mail")
- end
-
- it "raises an error when attempting to load a Cask that doesn't exist" do
- lambda {
- Hbc.load("notacask")
- }.must_raise(Hbc::CaskUnavailableError)
- end
- end
-
- describe "all_tokens" do
- it "returns a token for every Cask" do
- all_cask_tokens = Hbc.all_tokens
- all_cask_tokens.count.must_be :>, 20
- all_cask_tokens.each { |token| token.must_be_kind_of String }
- end
- end
-
- describe "metadata" do
- it "proposes a versioned metadata directory name for each instance" do
- cask_token = "adium"
- c = Hbc.load(cask_token)
- metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version)
- c.metadata_versioned_container_path.to_s.must_equal(metadata_path.to_s)
- end
- end
-end