This repository has been archived by the owner on Oct 27, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ebc283
commit 4661dec
Showing
4 changed files
with
77 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
module Spec | |||
module Expectations | |||
class << self | |||
attr_accessor :differ | |||
|
|||
def fail | |||
end | |||
|
|||
# raises a Spec::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 (Array === message) & (message.length == 3) | |||
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(Spec::Expectations::ExpectationNotMetError.new(message)) | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters