Method: Spec::Expectations.fail_with
- Defined in:
- lib/spec/expectations.rb
.fail_with(message, expected = nil, target = nil) ⇒ Object
raises a Spec::Expectations::ExpectationNotMetError with message
When a differ has been assigned and fail_with is passed expected and target, passes them to the differ to append a diff message to the failure message.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/spec/expectations.rb', line 46 def self.fail_with(, expected=nil, target=nil) # :nodoc: if Array === && .length == 3 , expected, target = [0], [1], [2] end unless (differ.nil? || expected.nil? || target.nil?) if expected.is_a?(String) << "\nDiff:" << self.differ.diff_as_string(target.to_s, expected) elsif !target.is_a?(Proc) << "\nDiff:" << self.differ.diff_as_object(target, expected) end end Kernel::raise(Spec::Expectations::ExpectationNotMetError.new()) end |