/usr/lib/ruby/vendor_ruby/rspec/support/matcher_definition.rb is in ruby-rspec-support 3.5.0c3e0m0s0-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 | module RSpec
module Support
# @private
def self.matcher_definitions
@matcher_definitions ||= []
end
# Used internally to break cyclic dependency between mocks, expectations,
# and support. We don't currently have a consistent implementation of our
# matchers, though we are considering changing that:
# https://github.com/rspec/rspec-mocks/issues/513
#
# @private
def self.register_matcher_definition(&block)
matcher_definitions << block
end
# Remove a previously registered matcher. Useful for cleaning up after
# yourself in specs.
#
# @private
def self.deregister_matcher_definition(&block)
matcher_definitions.delete(block)
end
# @private
def self.is_a_matcher?(object)
matcher_definitions.any? { |md| md.call(object) }
end
# @api private
#
# gives a string representation of an object for use in RSpec descriptions
def self.rspec_description_for_object(object)
if RSpec::Support.is_a_matcher?(object) && object.respond_to?(:description)
object.description
else
object
end
end
end
end
|