Sha256: 94fa9bc040843a12e980effb2b338ce5fdd5b7233e7de61499535816c62292ce

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

require 'rspec/expectations/version'

# @!method be_an_existing_file
#   This matchers checks if <file> exists in filesystem
#
#   @return [Boolean] 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_all_commands

    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

RSpec::Matchers.alias_matcher :an_existing_file, :be_an_existing_file

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aruba-1.0.0.pre.alpha.4 lib/aruba/matchers/file/be_an_existing_file.rb
aruba-1.0.0.pre.alpha.3 lib/aruba/matchers/file/be_an_existing_file.rb