From 9d36734e40c064efc48a58d28da9b23c9158dedc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:19:51 +0100 Subject: Convert Info test to spec. --- Library/Homebrew/cask/spec/cask/cli/info_spec.rb | 110 +++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/info_test.rb | 110 ----------------------- 2 files changed, 110 insertions(+), 110 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/info_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/info_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/info_spec.rb b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb new file mode 100644 index 000000000..6977f81c3 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb @@ -0,0 +1,110 @@ +require "spec_helper" + +describe Hbc::CLI::Info do + it "displays some nice info about the specified Cask" do + expect { + Hbc::CLI::Info.run("local-caffeine") + }.to output(<<-EOS.undent).to_stdout + local-caffeine: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + EOS + end + + describe "given multiple Casks" do + let(:expected_output) { + <<-EOS.undent + local-caffeine: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + local-transmission: 2.61 + http://example.com/local-transmission + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb + ==> Name + None + ==> Artifacts + Transmission.app (app) + EOS + } + + it "displays the info" do + expect { + Hbc::CLI::Info.run("local-caffeine", "local-transmission") + }.to output(expected_output).to_stdout + end + + it "throws away stray options" do + expect { + Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission") + }.to output(expected_output).to_stdout + end + end + + it "should print caveats if the Cask provided one" do + expect { + Hbc::CLI::Info.run("with-caveats") + }.to output(<<-EOS.undent).to_stdout + with-caveats: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + ==> Caveats + Here are some things you might want to know. + + Cask token: with-caveats + + Custom text via puts followed by DSL-generated text: + To use with-caveats, you may need to add the /custom/path/bin directory + to your PATH environment variable, eg (for bash shell): + + export PATH=/custom/path/bin:"$PATH" + + EOS + end + + it 'should not print "Caveats" section divider if the caveats block has no output' do + expect { + Hbc::CLI::Info.run("with-conditional-caveats") + }.to output(<<-EOS.undent).to_stdout + with-conditional-caveats: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + EOS + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Info.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Info.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/info_test.rb b/Library/Homebrew/cask/test/cask/cli/info_test.rb deleted file mode 100644 index 767a594e8..000000000 --- a/Library/Homebrew/cask/test/cask/cli/info_test.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Info do - it "displays some nice info about the specified Cask" do - lambda { - Hbc::CLI::Info.run("local-caffeine") - }.must_output <<-EOS.undent - local-caffeine: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - EOS - end - - describe "given multiple Casks" do - before do - @expected_output = <<-EOS.undent - local-caffeine: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - local-transmission: 2.61 - http://example.com/local-transmission - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-transmission.rb - ==> Name - None - ==> Artifacts - Transmission.app (app) - EOS - end - - it "displays the info" do - lambda { - Hbc::CLI::Info.run("local-caffeine", "local-transmission") - }.must_output(@expected_output) - end - - it "throws away stray options" do - lambda { - Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission") - }.must_output(@expected_output) - end - end - - it "should print caveats if the Cask provided one" do - lambda { - Hbc::CLI::Info.run("with-caveats") - }.must_output <<-EOS.undent - with-caveats: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-caveats.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - ==> Caveats - Here are some things you might want to know. - - Cask token: with-caveats - - Custom text via puts followed by DSL-generated text: - To use with-caveats, you may need to add the /custom/path/bin directory - to your PATH environment variable, eg (for bash shell): - - export PATH=/custom/path/bin:"$PATH" - - EOS - end - - it 'should not print "Caveats" section divider if the caveats block has no output' do - lambda { - Hbc::CLI::Info.run("with-conditional-caveats") - }.must_output <<-EOS.undent - with-conditional-caveats: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-conditional-caveats.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - EOS - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Info.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::Info.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3