Create custom matchers for “valid symlink”.
This commit is contained in:
parent
11abfc39ab
commit
6cd3642850
@ -20,7 +20,7 @@ describe Hbc::Artifact::Binary do
|
||||
shutup do
|
||||
Hbc::Artifact::Binary.new(cask).install_phase
|
||||
end
|
||||
expect(FileHelper.valid_alias?(expected_path)).to be true
|
||||
expect(expected_path).to be_a_valid_symlink
|
||||
end
|
||||
|
||||
it "avoids clobbering an existing binary by linking over it" do
|
||||
@ -82,7 +82,7 @@ describe Hbc::Artifact::Binary do
|
||||
Hbc::Artifact::Binary.new(cask).install_phase
|
||||
end
|
||||
|
||||
expect(FileHelper.valid_alias?(expected_path)).to be true
|
||||
expect(expected_path).to be_a_valid_symlink
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -34,4 +34,5 @@ end
|
||||
RSpec.configure do |config|
|
||||
config.order = :random
|
||||
config.include(Test::Helper::Shutup)
|
||||
config.include(FileMatchers)
|
||||
end
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
module FileHelper
|
||||
module_function
|
||||
|
||||
def valid_alias?(candidate)
|
||||
return false unless candidate.symlink?
|
||||
candidate.readlink.exist?
|
||||
end
|
||||
end
|
||||
9
Library/Homebrew/cask/spec/support/file_matchers.rb
Normal file
9
Library/Homebrew/cask/spec/support/file_matchers.rb
Normal file
@ -0,0 +1,9 @@
|
||||
module FileMatchers
|
||||
extend RSpec::Matchers::DSL
|
||||
|
||||
matcher :be_a_valid_symlink do
|
||||
match do |path|
|
||||
path.symlink? && path.readlink.exist?
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -20,7 +20,7 @@ describe Hbc::Artifact::Suite do
|
||||
end
|
||||
|
||||
target_path.must_be :directory?
|
||||
TestHelper.valid_alias?(target_path).must_equal false
|
||||
TestHelper.valid_symlink?(target_path).must_equal false
|
||||
source_path.wont_be :exist?
|
||||
end
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ class TestHelper
|
||||
"file://" + local_binary_path(name)
|
||||
end
|
||||
|
||||
def self.valid_alias?(candidate)
|
||||
def self.valid_symlink?(candidate)
|
||||
return false unless candidate.symlink?
|
||||
candidate.readlink.exist?
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user