Class: RSpec::Matchers::MultiMatcherDiff Private
- Inherits:
-
Object
- Object
- RSpec::Matchers::MultiMatcherDiff
- Defined in:
- lib/rspec/matchers/multi_matcher_diff.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Handles list of expected and actual value pairs when there is a need to render multiple diffs. Also can handle one pair.
Class Method Summary collapse
-
.for_many_matchers(matchers) ⇒ RSpec::Matchers::MultiMatcherDiff
private
Wraps provided matcher list in instance of MultiMatcherDiff.
-
.from(expected, actual) ⇒ RSpec::Matchers::MultiMatcherDiff
private
Wraps provided expected value in instance of MultiMatcherDiff.
Instance Method Summary collapse
-
#initialize(expected_list) ⇒ MultiMatcherDiff
constructor
private
A new instance of MultiMatcherDiff.
-
#message_with_diff(message, differ) ⇒ String
private
Returns message with diff(s) appended for provided differ factory and actual value if there are any.
Constructor Details
#initialize(expected_list) ⇒ MultiMatcherDiff
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MultiMatcherDiff.
16 17 18 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 16 def initialize(expected_list) @expected_list = expected_list end |
Class Method Details
.for_many_matchers(matchers) ⇒ RSpec::Matchers::MultiMatcherDiff
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wraps provided matcher list in instance of MultiMatcherDiff.
37 38 39 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 37 def self.for_many_matchers(matchers) new(matchers.map { |m| [m.expected, diff_label_for(m), m.actual] }) end |
.from(expected, actual) ⇒ RSpec::Matchers::MultiMatcherDiff
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wraps provided expected value in instance of MultiMatcherDiff. If provided value is already an MultiMatcherDiff then it just returns it.
27 28 29 30 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 27 def self.from(expected, actual) return expected if self === expected new([[expected, DEFAULT_DIFF_LABEL, actual]]) end |
Instance Method Details
#message_with_diff(message, differ) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns message with diff(s) appended for provided differ factory and actual value if there are any
47 48 49 50 51 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 47 def (, differ) diff = diffs(differ) = "#{}\n#{diff}" unless diff.empty? end |