This file is indexed.

/usr/lib/ruby/vendor_ruby/cheffish/rspec/matchers/partially_match.rb is in ruby-cheffish 4.0.0-1.

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
module Cheffish
  module RSpec
    module Matchers
      class PartiallyMatch
        include ::RSpec::Matchers::Composable

        def initialize(example, expected)
          @example = example
          @expected = expected
        end

        def matches?(actual)
          @actual = actual
          partially_matches_values(@expected, actual)
        end

        def failure_message
          "expected #{@actual} to match #{@expected}"
        end

        def failure_message_when_negated
          "expected #{@actual} not to match #{@expected}"
        end

        protected

        def partially_matches_values(expected, actual)
          if Hash === actual
            return partially_matches_hashes(expected, actual) if Hash === expected || Array === expected
          elsif Array === expected && Enumerable === actual && !(Struct === actual)
            return partially_matches_arrays(expected, actual)
          end

          return true if actual == expected

          begin
            expected === actual
          rescue ArgumentError
            # Some objects, like 0-arg lambdas on 1.9+, raise
            # ArgumentError for `expected === actual`.
            false
          end
        end

        def partially_matches_hashes(expected, actual)
          expected.all? { |key, value| partially_matches_values(value, actual[key]) }
        end

        def partially_matches_arrays(expected, actual)
          expected.all? { |e| actual.any? { |a| partially_matches_values(e, a) } }
        end
      end
    end
  end
end

module RSpec
  module Matchers
    def partially_match(expected)
      Cheffish::RSpec::Matchers::PartiallyMatch.new(self, expected)
    end
  end
end