Sha256: d7b4ac652ec642f304352c849e54474ccd6022f1d7007f5955cecbfd377811f0
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
module Rspec module Expectations class << self attr_accessor :differ # raises a Rspec::Expectations::ExpectationNotMetError with message # # When a differ has been assigned and fail_with is passed # <code>expected</code> and <code>target</code>, passes them # to the differ to append a diff message to the failure message. def fail_with(message, expected=nil, target=nil) # :nodoc: if message.nil? raise ArgumentError, "Failure message is nil. Does your matcher define the " + "appropriate failure_message_for_* method to return a string?" end if (Array === message) & (message.length == 3) ::Rspec::Core.warn(<<-NOTICE ***************************************************************** DEPRECATION WARNING: you are using deprecated behaviour that will be removed from a future version of RSpec. * Support for matchers that return arrays from failure message methods is deprecated. * Instead, the matcher should return a string, and expose methods for the expected() and actual() values. ***************************************************************** NOTICE ) message, expected, target = message[0], message[1], message[2] end unless (differ.nil? || expected.nil? || target.nil?) if expected.is_a?(String) message << "\nDiff:" << self.differ.diff_as_string(target.to_s, expected) elsif !target.is_a?(Proc) message << "\nDiff:" << self.differ.diff_as_object(target, expected) end end Kernel::raise(Rspec::Expectations::ExpectationNotMetError.new(message)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-expectations-2.0.0.a2 | lib/rspec/expectations/fail_with.rb |
rspec-expectations-2.0.0.a1 | lib/rspec/expectations/fail_with.rb |