Sha256: eac35a9f4d1c5336d3135e4c463040b16ba67aa18f47c7f2d18bea58f186d6b4

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

# @!method match_path_pattern(pattern)
#   This matchers checks if <files>/directories match <pattern>
#
#   @param [String, Regexp] pattern
#     The pattern to use.
#
#   @return [TrueClass, FalseClass] The result
#
#     false:
#     * if there are no files/directories which match the pattern
#     true:
#     * if there are files/directories which match the pattern
#
#   @example Use matcher with regex
#
#     RSpec.describe do
#       it { expect(Dir.glob(**/*)).to match_file_pattern(/.txt$/) }
#     end
#
#   @example Use matcher with string
#
#     RSpec.describe do
#       it { expect(Dir.glob(**/*)).to match_file_pattern('.txt$') }
#     end
RSpec::Matchers.define :match_path_pattern do |_|
  match do |actual|
    Aruba.platform.deprecated('The use of `expect().to match_path_pattern` is deprecated. Please use `expect().to include pattern /regex/` instead.')

    next !actual.select { |a| a == expected }.empty? if expected.is_a? String

    !actual.grep(expected).empty?
  end

  failure_message do |actual|
    format("expected that path \"%s\" matches pattern \"%s\".", actual.join(", "), expected)
  end

  failure_message_when_negated do |actual|
    format("expected that path \"%s\" does not match pattern \"%s\".", actual.join(", "), expected)
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

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