diff options
| author | Markus Reiter | 2017-02-08 12:05:42 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-02-10 17:19:19 +0100 |
| commit | dcb206dd1ef1be09f75774c0f86692ad3e31c679 (patch) | |
| tree | ad3c16267f82d37a068a9a5f504b851ee26a3e91 /Library/Homebrew/cask/test | |
| parent | 2ade29a5cf5df84ed9fb7dcf429c59c3e084a6a1 (diff) | |
| download | brew-dcb206dd1ef1be09f75774c0f86692ad3e31c679.tar.bz2 | |
Convert Create test to spec.
Diffstat (limited to 'Library/Homebrew/cask/test')
| -rw-r--r-- | Library/Homebrew/cask/test/cask/cli/create_test.rb | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/Library/Homebrew/cask/test/cask/cli/create_test.rb b/Library/Homebrew/cask/test/cask/cli/create_test.rb deleted file mode 100644 index f09c91e8e..000000000 --- a/Library/Homebrew/cask/test/cask/cli/create_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -require "test_helper" - -# monkeypatch for testing -module Hbc - class CLI - class Create - def self.exec_editor(*command) - editor_commands << command - end - - def self.reset! - @editor_commands = [] - end - - def self.editor_commands - @editor_commands ||= [] - end - end - end -end - -describe Hbc::CLI::Create do - before do - Hbc::CLI::Create.reset! - end - - after do - %w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask| - path = Hbc.path(cask) - path.delete if path.exist? - end - end - - it "opens the editor for the specified Cask" do - Hbc::CLI::Create.run("new-cask") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("new-cask")], - ] - end - - it "drops a template down for the specified Cask" do - Hbc::CLI::Create.run("new-cask") - template = File.read(Hbc.path("new-cask")) - template.must_equal <<-EOS.undent - cask 'new-cask' do - version '' - sha256 '' - - url 'https://' - name '' - homepage '' - - app '' - end - EOS - end - - it "throws away additional Cask arguments and uses the first" do - Hbc::CLI::Create.run("additional-cask", "another-cask") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("additional-cask")], - ] - end - - it "throws away stray options" do - Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("yet-another-cask")], - ] - end - - it "raises an exception when the Cask already exists" do - lambda { - Hbc::CLI::Create.run("basic-cask") - }.must_raise Hbc::CaskAlreadyCreatedError - end - - it "allows creating Casks that are substrings of existing Casks" do - Hbc::CLI::Create.run("local-caff") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("local-caff")], - ] - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Create.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Create.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end |
