This file is indexed.

/usr/lib/ruby/vendor_ruby/rspec/mocks/any_instance/message_chains.rb is in ruby-rspec-mocks 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
module RSpec
  module Mocks
    module AnyInstance
      # @private
      class MessageChains
        def initialize
          @chains_by_method_name = Hash.new { |h, k| h[k] = [] }
        end

        # @private
        def [](method_name)
          @chains_by_method_name[method_name]
        end

        # @private
        def add(method_name, chain)
          @chains_by_method_name[method_name] << chain
          chain
        end

        # @private
        def remove_stub_chains_for!(method_name)
          @chains_by_method_name[method_name].reject! do |chain|
            StubChain === chain
          end
        end

        # @private
        def has_expectation?(method_name)
          @chains_by_method_name[method_name].find do |chain|
            ExpectationChain === chain
          end
        end

        # @private
        def each_unfulfilled_expectation_matching(method_name, *args)
          @chains_by_method_name[method_name].each do |chain|
            yield chain if !chain.expectation_fulfilled? && chain.matches_args?(*args)
          end
        end

        # @private
        def all_expectations_fulfilled?
          @chains_by_method_name.all? do |_method_name, chains|
            chains.all? { |chain| chain.expectation_fulfilled? }
          end
        end

        # @private
        def unfulfilled_expectations
          @chains_by_method_name.map do |method_name, chains|
            method_name.to_s if ExpectationChain === chains.last unless chains.last.expectation_fulfilled?
          end.compact
        end

        # @private
        def received_expected_message!(method_name)
          @chains_by_method_name[method_name].each do |chain|
            chain.expectation_fulfilled!
          end
        end

        # @private
        def playback!(instance, method_name)
          raise_if_second_instance_to_receive_message(instance)
          @chains_by_method_name[method_name].each do |chain|
            chain.playback!(instance)
          end
        end

      private

        def raise_if_second_instance_to_receive_message(instance)
          @instance_with_expectation ||= instance if ExpectationChain === instance
          return unless ExpectationChain === instance
          return if @instance_with_expectation.equal?(instance)

          AnyInstance.error_generator.raise_second_instance_received_message_error(unfulfilled_expectations)
        end
      end
    end
  end
end