diff options
| author | Markus Reiter | 2017-03-05 06:31:36 +0100 | 
|---|---|---|
| committer | Markus Reiter | 2017-03-05 23:08:14 +0100 | 
| commit | 9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch) | |
| tree | 43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/cask/artifact/binary_spec.rb | |
| parent | 67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff) | |
| download | brew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2 | |
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/cask/artifact/binary_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/cask/artifact/binary_spec.rb | 90 | 
1 files changed, 90 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb new file mode 100644 index 000000000..1b26773ca --- /dev/null +++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb @@ -0,0 +1,90 @@ +describe Hbc::Artifact::Binary, :cask do +  let(:cask) { +    Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask| +      shutup do +        InstallHelper.install_without_artifacts(cask) +      end +    end +  } +  let(:expected_path) { +    Hbc.binarydir.join("binary") +  } +  before(:each) do +    Hbc.binarydir.mkpath +  end +  after(:each) do +    FileUtils.rm expected_path if expected_path.exist? +  end + +  it "links the binary to the proper directory" do +    shutup do +      Hbc::Artifact::Binary.new(cask).install_phase +    end +    expect(expected_path).to be_a_symlink +    expect(expected_path.readlink).to exist +  end + +  it "avoids clobbering an existing binary by linking over it" do +    FileUtils.touch expected_path + +    expect { +      shutup do +        Hbc::Artifact::Binary.new(cask).install_phase +      end +    }.to raise_error(Hbc::CaskError) + +    expect(expected_path).not_to be :symlink? +  end + +  it "clobbers an existing symlink" do +    expected_path.make_symlink("/tmp") + +    shutup do +      Hbc::Artifact::Binary.new(cask).install_phase +    end + +    expect(File.readlink(expected_path)).not_to eq("/tmp") +  end + +  it "respects --no-binaries flag" do +    Hbc.no_binaries = true + +    shutup do +      Hbc::Artifact::Binary.new(cask).install_phase +    end + +    expect(expected_path.exist?).to be false + +    Hbc.no_binaries = false +  end + +  it "creates parent directory if it doesn't exist" do +    FileUtils.rmdir Hbc.binarydir + +    shutup do +      Hbc::Artifact::Binary.new(cask).install_phase +    end + +    expect(expected_path.exist?).to be true +  end + +  context "binary is inside an app package" do +    let(:cask) { +      Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask| +        shutup do +          InstallHelper.install_without_artifacts(cask) +        end +      end +    } + +    it "links the binary to the proper directory" do +      shutup do +        Hbc::Artifact::App.new(cask).install_phase +        Hbc::Artifact::Binary.new(cask).install_phase +      end + +      expect(expected_path).to be_a_symlink +      expect(expected_path.readlink).to exist +    end +  end +end  | 
