From 24d50599410dacbb36decfc957a5933e19d6a205 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 14:25:50 +0100 Subject: Convert generic artifact test to spec. --- .../spec/cask/artifact/generic_artifact_spec.rb | 47 ++++++++++++++++++++++ .../test/cask/artifact/generic_artifact_test.rb | 47 ---------------------- 2 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb new file mode 100644 index 000000000..7d9128c0e --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb @@ -0,0 +1,47 @@ +require "spec_helper" + +describe Hbc::Artifact::Artifact do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } + + let(:install_phase) { + -> { Hbc::Artifact::Artifact.new(cask).install_phase } + } + + let(:source_path) { cask.staged_path.join("Caffeine.app") } + let(:target_path) { Hbc.appdir.join("Caffeine.app") } + + before do + InstallHelper.install_without_artifacts(cask) + end + + describe "with no target" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") } + + it "fails to install with no target" do + expect(install_phase).to raise_error(Hbc::CaskInvalidError) + end + end + + it "moves the artifact to the proper directory" do + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(source_path).not_to exist + end + + it "avoids clobbering an existing artifact" do + target_path.mkpath + + expect { + shutup do + install_phase.call + end + }.to raise_error(Hbc::CaskError) + + expect(source_path).to be_a_directory + expect(target_path).to be_a_directory + expect(File.identical?(source_path, target_path)).to be false + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb b/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb deleted file mode 100644 index 21584b92a..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Artifact do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } - - let(:install_phase) { - -> { Hbc::Artifact::Artifact.new(cask).install_phase } - } - - let(:source_path) { cask.staged_path.join("Caffeine.app") } - let(:target_path) { Hbc.appdir.join("Caffeine.app") } - - before do - TestHelper.install_without_artifacts(cask) - end - - describe "with no target" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") } - - it "fails to install with no target" do - install_phase.must_raise Hbc::CaskInvalidError - end - end - - it "moves the artifact to the proper directory" do - shutup do - install_phase.call - end - - target_path.must_be :directory? - source_path.wont_be :exist? - end - - it "avoids clobbering an existing artifact" do - target_path.mkpath - - assert_raises Hbc::CaskError do - shutup do - install_phase.call - end - end - - source_path.must_be :directory? - target_path.must_be :directory? - File.identical?(source_path, target_path).must_equal false - end -end -- cgit v1.2.3