This file is indexed.

/usr/lib/ruby/vendor_ruby/rspec/matchers/built_in/all.rb is in ruby-rspec-expectations 3.4.0c3e0m1s1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module RSpec
  module Matchers
    module BuiltIn
      # @api private
      # Provides the implementation for `all`.
      # Not intended to be instantiated directly.
      class All < BaseMatcher
        # @private
        attr_reader :matcher, :failed_objects

        def initialize(matcher)
          @matcher = matcher
          @failed_objects = {}
        end

        # @private
        def does_not_match?(_actual)
          raise NotImplementedError, '`expect().not_to all( matcher )` is not supported.'
        end

        # @api private
        # @return [String]
        def failure_message
          unless iterable?
            return "#{improve_hash_formatting(super)}, but was not iterable"
          end

          all_messages = [improve_hash_formatting(super)]
          failed_objects.each do |index, matcher_failure_message|
            all_messages << failure_message_for_item(index, matcher_failure_message)
          end
          all_messages.join("\n\n")
        end

        # @api private
        # @return [String]
        def description
          improve_hash_formatting "all #{description_of matcher}"
        end

      private

        def match(_expected, _actual)
          return false unless iterable?

          index_failed_objects
          failed_objects.empty?
        end

        def index_failed_objects
          actual.each_with_index do |actual_item, index|
            cloned_matcher = matcher.clone
            matches = cloned_matcher.matches?(actual_item)
            failed_objects[index] = cloned_matcher.failure_message unless matches
          end
        end

        def failure_message_for_item(index, failure_message)
          failure_message = indent_multiline_message(add_new_line_if_needed(failure_message))
          indent_multiline_message("object at index #{index} failed to match:#{failure_message}")
        end

        def add_new_line_if_needed(message)
          message.start_with?("\n") ? message : "\n#{message}"
        end

        def indent_multiline_message(message)
          message = message.sub(/\n+\z/, '')
          message.lines.map do |line|
            line =~ /\S/ ? '   ' + line : line
          end.join
        end

        def initialize_copy(other)
          @matcher = @matcher.clone
          super
        end

        def iterable?
          @actual.respond_to?(:each_with_index)
        end
      end
    end
  end
end