Class: RSpec::Matchers::AliasedNegatedMatcher Private
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
RSpec::Matchers::AliasedMatcher
|
| Defined in: | rspec-expectations/lib/rspec/matchers/aliased_matcher.rb |
Constant Summary
-
DefaultFailureMessages =
# File 'rspec-expectations/lib/rspec/matchers/aliased_matcher.rb', line 94BuiltIn::BaseMatcher::DefaultFailureMessages
Class Method Summary
Instance Attribute Summary
MatcherDelegator - Inherited
Instance Method Summary
- #does_not_match?(*args, &block) ⇒ Boolean Internal use only
- #failure_message Internal use only
- #failure_message_when_negated Internal use only
- #matches?(*args, &block) ⇒ Boolean Internal use only
-
#optimal_failure_message(same, inverted)
private
Internal use only
For a matcher that uses the default failure messages, we prefer to use the override provided by the
description_block, because it includes the phrasing that the user has expressed a preference for by going through the effort of defining a negated matcher.
AliasedMatcher - Inherited
| #description | Provides the description of the aliased matcher. |
| #failure_message | Provides the failure_message of the aliased matcher. |
| #failure_message_when_negated | Provides the failure_message_when_negated of the aliased matcher. |
| #method_missing | Forward messages on to the wrapped matcher. |
MatcherDelegator - Inherited
Composable - Included
| #& | Alias for Composable#and. |
| #=== | Delegates to #matches?. |
| #and | Creates a compound |
| #description_of | Returns the description of the given object in a way that is aware of composed matchers. |
| #or | Creates a compound |
| #values_match? | This provides a generic way to fuzzy-match an expected value against an actual value. |
| #| | Alias for Composable#or. |
| #should_enumerate? | We should enumerate arrays as long as they are not recursive. |
| #surface_descriptions_in | Transforms the given data structure (typically a hash or array) into a new data structure that, when |
| #unreadable_io?, | |
| #with_matchers_cloned | Historically, a single matcher instance was only checked against a single value. |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RSpec::Matchers::AliasedMatcher
Instance Method Details
#does_not_match?(*args, &block) ⇒ Boolean
# File 'rspec-expectations/lib/rspec/matchers/aliased_matcher.rb', line 80
def does_not_match?(*args, &block) @base_matcher.matches?(*args, &block) end
#failure_message
[ GitHub ]# File 'rspec-expectations/lib/rspec/matchers/aliased_matcher.rb', line 84
def (__method__, :) end
#failure_message_when_negated
[ GitHub ]# File 'rspec-expectations/lib/rspec/matchers/aliased_matcher.rb', line 88
def (__method__, :) end
#matches?(*args, &block) ⇒ Boolean
# File 'rspec-expectations/lib/rspec/matchers/aliased_matcher.rb', line 72
def matches?(*args, &block) if @base_matcher.respond_to?(:does_not_match?) @base_matcher.does_not_match?(*args, &block) else !super end end
#optimal_failure_message(same, inverted) (private)
For a matcher that uses the default failure messages, we prefer to use the override provided by the description_block, because it includes the phrasing that the user has expressed a preference for by going through the effort of defining a negated matcher.
However, if the override didn’t actually change anything, then we should return the opposite failure message instead – the overridden message is going to be confusing if we return it as-is, as it represents the non-negated failure message for a negated match (or vice versa).
# File 'rspec-expectations/lib/rspec/matchers/aliased_matcher.rb', line 105
def (same, inverted) if DefaultFailureMessages.(@base_matcher) = @base_matcher.__send__(same) overridden = @description_block.call() return overridden if overridden != end @base_matcher.__send__(inverted) end