Sha256: 66ab5ba7e332961ff70ff9d60a6ae6fea6dbd4efa6b09ca67f477e0b96ae02cc

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

require 'rspec/expectations/version'

# @!method be_an_existing_file
#   This matchers checks if <file> exists in filesystem
#
#   @return [TrueClass, FalseClass] The result
#
#     false:
#     * if file does not exist
#     true:
#     * if file exists
#
#   @example Use matcher
#
#     RSpec.describe do
#       it { expect(file1).to be_an_existing_file }
#     end
RSpec::Matchers.define :be_an_existing_file do |_|
  match do |actual|
    stop_processes!

    next false unless actual.is_a? String

    file?(actual)
  end

  failure_message do |actual|
    format("expected that file \"%s\" exists", actual)
  end

  failure_message_when_negated do |actual|
    format("expected that file \"%s\" does not exist", actual)
  end
end

if RSpec::Expectations::Version::STRING >= '3.0'
  RSpec::Matchers.alias_matcher :an_existing_file, :be_an_existing_file
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aruba-0.9.0.pre lib/aruba/matchers/file/be_an_existing_file.rb
aruba-0.8.1 lib/aruba/matchers/file/be_an_existing_file.rb
aruba-0.8.0 lib/aruba/matchers/file/be_an_existing_file.rb
aruba-0.8.0.pre3 lib/aruba/matchers/file/be_an_existing_file.rb