Class: RSpec::Matchers::BuiltIn::Compound Private

Inherits:
BaseMatcher
  • Object
show all
Defined in:
lib/rspec/matchers/built_in/compound.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.

Base class for and and or compound matchers. rubocop:disable ClassLength

Direct Known Subclasses

And, Or

Defined Under Namespace

Classes: And, NestedEvaluator, Or, SequentialEvaluator

Constant Summary

Constant Summary

Constants inherited from BaseMatcher

BaseMatcher::UNDEFINED

Instance Method Summary (collapse)

Methods inherited from BaseMatcher

#match_unless_raises, #matches?

Methods included from BaseMatcher::DefaultFailureMessages

#failure_message, #failure_message_when_negated

Methods included from Composable

#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?

Constructor Details

- (Compound) initialize(matcher_1, matcher_2)

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 Compound

11
12
13
14
# File 'lib/rspec/matchers/built_in/compound.rb', line 11
def initialize(matcher_1, matcher_2)
  @matcher_1 = matcher_1
  @matcher_2 = matcher_2
end

Instance Method Details

- (String) description

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:

  • (String)
26
27
28
# File 'lib/rspec/matchers/built_in/compound.rb', line 26
def description
  "#{matcher_1.description} #{conjunction} #{matcher_2.description}"
end

- (Boolean) diffable?

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:

  • (Boolean)
42
43
44
# File 'lib/rspec/matchers/built_in/compound.rb', line 42
def diffable?
  matcher_is_diffable?(matcher_1) || matcher_is_diffable?(matcher_2)
end

- (RSpec::Matchers::ExpectedsForMultipleDiffs) expected

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.

48
49
50
51
# File 'lib/rspec/matchers/built_in/compound.rb', line 48
def expected
  return nil unless evaluator
  ::RSpec::Matchers::ExpectedsForMultipleDiffs.for_many_matchers(diffable_matcher_list)
end

- (Boolean) expects_call_stack_jump?

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:

  • (Boolean)
35
36
37
38
# File 'lib/rspec/matchers/built_in/compound.rb', line 35
def expects_call_stack_jump?
  NestedEvaluator.matcher_expects_call_stack_jump?(matcher_1) ||
  NestedEvaluator.matcher_expects_call_stack_jump?(matcher_2)
end

- (Boolean) supports_block_expectations?

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:

  • (Boolean)
30
31
32
33
# File 'lib/rspec/matchers/built_in/compound.rb', line 30
def supports_block_expectations?
  matcher_supports_block_expectations?(matcher_1) &&
  matcher_supports_block_expectations?(matcher_2)
end