Class: RSpec::SleepingKingStudios::Matchers::BaseMatcher
- Inherits:
-
Object
- Object
- RSpec::SleepingKingStudios::Matchers::BaseMatcher
- Includes:
- Description
- Defined in:
- lib/rspec/sleeping_king_studios/matchers/base_matcher.rb
Overview
Minimal implementation of the RSpec matcher interface.
Direct Known Subclasses
ActiveModel::HaveErrorsMatcher, Core::BeAUuidMatcher, Core::BeBooleanMatcher, Core::ConstructMatcher, Core::DeepMatcher, Core::DelegateMethodMatcher, Core::HaveAliasedMethodMatcher, Core::HaveChangedMatcher, Core::HaveConstantMatcher, Core::HavePredicateMatcher, Core::HavePropertyMatcher, Core::HaveReaderMatcher, Core::HaveWriterMatcher
Constant Summary
Constants included from Description
Description::DEFAULT_EXPECTED_ITEMS
Instance Attribute Summary collapse
- #actual ⇒ Object readonly
Instance Method Summary collapse
-
#does_not_match?(actual) ⇒ Boolean
Inverse of #matches? method.
-
#failure_message ⇒ Object
Message for when the object does not match, but was expected to.
-
#failure_message_when_negated ⇒ Object
Message for when the object matches, but was expected not to.
-
#matches?(actual) ⇒ Boolean
Tests the actual object to see if it matches the defined condition(s).
Methods included from Description
Instance Attribute Details
#actual ⇒ Object (readonly)
15 16 17 |
# File 'lib/rspec/sleeping_king_studios/matchers/base_matcher.rb', line 15 def actual @actual end |
Instance Method Details
#does_not_match?(actual) ⇒ Boolean
Inverse of #matches? method.
24 25 26 |
# File 'lib/rspec/sleeping_king_studios/matchers/base_matcher.rb', line 24 def does_not_match? actual !matches?(actual) end |
#failure_message ⇒ Object
Message for when the object does not match, but was expected to. Make sure to always call #matches? first to set up the matcher state.
42 43 44 |
# File 'lib/rspec/sleeping_king_studios/matchers/base_matcher.rb', line 42 def "expected #{@actual.inspect} to #{description}" end |
#failure_message_when_negated ⇒ Object
Message for when the object matches, but was expected not to. Make sure to always call #matches? first to set up the matcher state.
48 49 50 |
# File 'lib/rspec/sleeping_king_studios/matchers/base_matcher.rb', line 48 def "expected #{@actual.inspect} not to #{description}" end |
#matches?(actual) ⇒ Boolean
Tests the actual object to see if it matches the defined condition(s). Invoked by RSpec expectations.
34 35 36 37 38 |
# File 'lib/rspec/sleeping_king_studios/matchers/base_matcher.rb', line 34 def matches? actual @actual = actual true end |