Sha256: 522d7950fac05851dc366a9f960e8b591a715d0cd2b82dade91d01130fce155b

Contents?: true

Size: 1022 Bytes

Versions: 21

Compression:

Stored size: 1022 Bytes

Contents

require 'rspec/expectations/version'

# @!method be_a_command_found_in_path
#   This matchers checks if <command> can be found in path
#
#   @return [TrueClass, FalseClass] The result
#
#     false:
#     * if command was not found in PATH
#     true:
#     * if command can be found in PATH
#
#   @example Use matcher
#
#     RSpec.describe do
#       it { expect(cmd).to be_a_command_found_in_path }
#     end
RSpec::Matchers.define :be_a_command_found_in_path do
  match do |actual|
    @actual = Shellwords.split(actual.commandline).first if actual.respond_to? :commandline

    !which(@actual).nil?
  end

  failure_message do |actual|
    format(%(expected that command "%s" can be found in PATH "#{ENV['PATH']}".), actual)
  end

  failure_message_when_negated do |actual|
    format(%(expected that command "%s" cannot be found in PATH "#{ENV['PATH']}".), actual)
  end
end

if RSpec::Expectations::Version::STRING >= '3.0'
  RSpec::Matchers.alias_matcher :a_command_found_in_path, :be_a_command_found_in_path
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
aruba-0.14.14 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.13 lib/aruba/matchers/file/be_a_command_found_in_path.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/aruba-0.14.12/lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.12 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.11 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.10 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.9 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.8 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.7 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.6 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.5 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.4 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.3 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-1.0.0.pre.alpha.2 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-1.0.0.pre.alpha.1 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-win-fix-0.14.2 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.2 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.1 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.14.0 lib/aruba/matchers/file/be_a_command_found_in_path.rb
aruba-0.13.0 lib/aruba/matchers/file/be_a_command_found_in_path.rb