/usr/lib/ruby/vendor_ruby/rspec/expectations/fail_with.rb is in ruby-rspec-expectations 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 | module RSpec
module Expectations
class << self
# @private
def differ
RSpec::Support::Differ.new(
:object_preparer => lambda { |object| RSpec::Matchers::Composable.surface_descriptions_in(object) },
:color => RSpec::Matchers.configuration.color?
)
end
# Raises an RSpec::Expectations::ExpectationNotMetError with message.
# @param [String] message
# @param [Object] expected
# @param [Object] actual
#
# Adds a diff to the failure message when `expected` and `actual` are
# both present.
def fail_with(message, expected=nil, actual=nil)
unless message
raise ArgumentError, "Failure message is nil. Does your matcher define the " \
"appropriate failure_message[_when_negated] method to return a string?"
end
message = ::RSpec::Matchers::ExpectedsForMultipleDiffs.from(expected).message_with_diff(message, differ, actual)
RSpec::Support.notify_failure(RSpec::Expectations::ExpectationNotMetError.new message)
end
end
end
end
|