Sha256: 87f7cd64241fd016ed420ed9e314ed654a104d560236e487545ea703fc864c3c

Contents?: true

Size: 1.18 KB

Versions: 42

Compression:

Stored size: 1.18 KB

Contents

require "rspec/expectations"
require "pathname"

RSpec::Matchers.define :be_relative_path do
  match do |given|
    if given.nil?
      false
    else
      Pathname.new(given).relative?
    end
  end

  failure_message do |given|
    "Expected '#{given}' to be a relative path but got an absolute path."
  end

  failure_message_when_negated do |given|
    "Expected '#{given}' to not be a relative path but got an absolute path."
  end
end

# expect('/path/to/directory').to be_a_directory
RSpec::Matchers.define :be_a_directory do
  match do |actual|
    File.directory?(actual)
  end
end

# expect('/path/to/directory').to be_a_file
RSpec::Matchers.define :be_a_file do
  match do |actual|
    File.file?(actual)
  end
end

# expect('/path/to/directory').to be_a_symlink
RSpec::Matchers.define :be_a_symlink do
  match do |actual|
    File.symlink?(actual)
  end
end

# expect('/path/to/directory').to be_a_symlink_to
RSpec::Matchers.define :be_a_symlink_to do |path|
  match do |actual|
    File.symlink?(actual) && File.readlink(actual) == path
  end
end

# expect('/path/to/file').to be_an_executable
RSpec::Matchers.define :be_an_executable do
  match do |actual|
    File.executable?(actual)
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
berkshelf-8.0.15 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.13 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.12 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.9 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.7 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.5 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.2 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.1 spec/support/matchers/filepath_matchers.rb
berkshelf-8.0.0 spec/support/matchers/filepath_matchers.rb
berkshelf-7.2.2 spec/support/matchers/filepath_matchers.rb
berkshelf-7.2.1 spec/support/matchers/filepath_matchers.rb
berkshelf-7.2.0 spec/support/matchers/filepath_matchers.rb
berkshelf-7.1.0 spec/support/matchers/filepath_matchers.rb
berkshelf-7.0.10 spec/support/matchers/filepath_matchers.rb
berkshelf-7.0.9 spec/support/matchers/filepath_matchers.rb
berkshelf-7.0.8 spec/support/matchers/filepath_matchers.rb
berkshelf-7.0.7 spec/support/matchers/filepath_matchers.rb
berkshelf-6.3.4 spec/support/matchers/filepath_matchers.rb
berkshelf-7.0.6 spec/support/matchers/filepath_matchers.rb
berkshelf-7.0.5 spec/support/matchers/filepath_matchers.rb