Sha256: c9fbf8d5ac81fa28895ab0262a066c11727ab2b13ba4a2d93d5feedd19f6550b

Contents?: true

Size: 853 Bytes

Versions: 5

Compression:

Stored size: 853 Bytes

Contents

require "shellwords"

# @!method be_an_existing_executable
#   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_executable }
#     end
RSpec::Matchers.define :be_an_existing_executable do |_|
  match do |actual|
    @actual = Shellwords.split(actual.commandline).first if actual.respond_to? :commandline

    executable?(@actual)
  end

  failure_message do |actual|
    format('expected that executable "%s" exists', actual)
  end

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

RSpec::Matchers.alias_matcher :an_existing_executable, :be_an_existing_executable

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/matchers/file/be_an_existing_executable.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/matchers/file/be_an_existing_executable.rb
aruba-2.2.0 lib/aruba/matchers/file/be_an_existing_executable.rb
aruba-2.1.0 lib/aruba/matchers/file/be_an_existing_executable.rb
aruba-2.0.1 lib/aruba/matchers/file/be_an_existing_executable.rb