aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/spec
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-08 12:15:34 +0100
committerMarkus Reiter2017-02-10 17:19:19 +0100
commit0daf01681268dd19ee5d154e484b3d97832f9ec9 (patch)
tree9e6af268a0ed5dfdacf03195c53b431557c3bb57 /Library/Homebrew/cask/spec
parente637eb414e880559695a71b3fc1efbc7104ee64e (diff)
downloadbrew-0daf01681268dd19ee5d154e484b3d97832f9ec9.tar.bz2
Convert Home test to spec.
Diffstat (limited to 'Library/Homebrew/cask/spec')
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/home_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/spec/cask/cli/home_spec.rb b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb
new file mode 100644
index 000000000..a2b49b433
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb
@@ -0,0 +1,48 @@
+require "spec_helper"
+
+# monkeypatch for testing
+module Hbc
+ class CLI
+ class Home
+ def self.system(*command)
+ system_commands << command
+ end
+
+ def self.reset!
+ @system_commands = []
+ end
+
+ def self.system_commands
+ @system_commands ||= []
+ end
+ end
+ end
+end
+
+describe Hbc::CLI::Home do
+ before do
+ Hbc::CLI::Home.reset!
+ end
+
+ it "opens the homepage for the specified Cask" do
+ Hbc::CLI::Home.run("local-caffeine")
+ expect(Hbc::CLI::Home.system_commands).to eq [
+ ["/usr/bin/open", "--", "http://example.com/local-caffeine"],
+ ]
+ end
+
+ it "works for multiple Casks" do
+ Hbc::CLI::Home.run("local-caffeine", "local-transmission")
+ expect(Hbc::CLI::Home.system_commands).to eq [
+ ["/usr/bin/open", "--", "http://example.com/local-caffeine"],
+ ["/usr/bin/open", "--", "http://example.com/local-transmission"],
+ ]
+ end
+
+ it "opens the project page when no Cask is specified" do
+ Hbc::CLI::Home.run
+ expect(Hbc::CLI::Home.system_commands).to eq [
+ ["/usr/bin/open", "--", "http://caskroom.io/"],
+ ]
+ end
+end