Class: RSpec::Matchers::ExpectedsForMultipleDiffs Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/expecteds_for_multiple_diffs.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 values when there is a need to render multiple diffs. Also can handle one value.

Constant Summary collapse

DEFAULT_DIFF_LABEL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Default diff label when there is only one matcher in diff output

"Diff:".freeze
DESCRIPTION_MAX_LENGTH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Maximum readable matcher description length

65

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_list) ⇒ ExpectedsForMultipleDiffs

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 ExpectedsForMultipleDiffs.



16
17
18
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/expecteds_for_multiple_diffs.rb', line 16

def initialize(expected_list)
  @expected_list = expected_list
end

Class Method Details

.for_many_matchers(matchers) ⇒ RSpec::Matchers::ExpectedsForMultipleDiffs

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 ExpectedForMultipleDiffs.

Parameters:

  • matchers (Array<Any>)

    list of matchers to wrap

Returns:



36
37
38
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/expecteds_for_multiple_diffs.rb', line 36

def self.for_many_matchers(matchers)
  new(matchers.map { |m| [m.expected, diff_label_for(m)] })
end

.from(expected) ⇒ RSpec::Matchers::ExpectedsForMultipleDiffs

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 ExpectedForMultipleDiffs. If provided value is already an ExpectedForMultipleDiffs then it just returns it.

Parameters:

  • expected (Any)

    value to be wrapped

Returns:



26
27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/expecteds_for_multiple_diffs.rb', line 26

def self.from(expected)
  return expected if self === expected
  new([[expected, DEFAULT_DIFF_LABEL]])
end

Instance Method Details

#message_with_diff(message, differ, actual) ⇒ 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

Parameters:

  • message (String)

    original failure message

  • differ (Proc)
  • actual (Any)

    value

Returns:



47
48
49
50
51
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/expecteds_for_multiple_diffs.rb', line 47

def message_with_diff(message, differ, actual)
  diff = diffs(differ, actual)
  message = "#{message}\n#{diff}" unless diff.empty?
  message
end