Class: RSpec::Matchers::BuiltIn::BaseMatcher Private
- Inherits:
-
Object
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- Includes:
- Pretty
- Defined in:
- lib/rspec/matchers/built_in/base_matcher.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.
Used internally as a base class for matchers that ship with rspec-expectations.
Warning:
This class is for internal use, and subject to change without notice. We strongly recommend that you do not base your custom matchers on this class. If/when this changes, we will announce it and remove this warning.
Direct Known Subclasses
Be, BeAKindOf, BeAnInstanceOf, BeFalse, BeNil, BePredicate, BeTrue, Cover, Eq, Eql, Equal, Exist, Include, Match, MatchArray, StartAndEndWith, YieldControl, YieldWithNoArgs
Constant Summary
- UNDEFINED =
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.
Object.new.freeze
Instance Attribute Summary (collapse)
- - (Object) actual readonly private
- - (Object) expected readonly private
- - (Object) rescued_exception readonly private
Instance Method Summary (collapse)
- - (Object) ==(other) private
- - (Object) description private
- - (Boolean) diffable? private
- - (Object) failure_message_for_should private
- - (Object) failure_message_for_should_not private
-
- (BaseMatcher) initialize(expected = UNDEFINED)
constructor
private
A new instance of BaseMatcher.
- - (Object) match_unless_raises(*exceptions) private
- - (Boolean) matches?(actual) private
Methods included from Pretty
#_pretty_print, #expected_to_sentence, #name, #name_to_sentence, #split_words, #to_sentence, #to_word, #underscore
Constructor Details
- (BaseMatcher) initialize(expected = UNDEFINED)
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.
A new instance of BaseMatcher
21 22 23 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 21 def initialize(expected = UNDEFINED) @expected = expected unless UNDEFINED.equal?(expected) end |
Instance Attribute Details
- (Object) actual (readonly)
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.
19 20 21 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 19 def actual @actual end |
- (Object) expected (readonly)
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.
19 20 21 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 19 def expected @expected end |
- (Object) rescued_exception (readonly)
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.
19 20 21 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 19 def rescued_exception @rescued_exception end |
Instance Method Details
- (Object) ==(other)
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.
58 59 60 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 58 def ==(other) matches?(other) end |
- (Object) 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.
50 51 52 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 50 def description defined?(@expected) ? "#{name_to_sentence} #{@expected.inspect}" : name_to_sentence 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.
54 55 56 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 54 def diffable? false end |
- (Object) failure_message_for_should
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.
40 41 42 43 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 40 def assert_ivars :@actual "expected #{@actual.inspect} to #{name_to_sentence}#{expected_to_sentence}" end |
- (Object) failure_message_for_should_not
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.
45 46 47 48 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 45 def assert_ivars :@actual "expected #{@actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}" end |
- (Object) match_unless_raises(*exceptions)
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.
30 31 32 33 34 35 36 37 38 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 30 def match_unless_raises(*exceptions) exceptions.unshift Exception if exceptions.empty? begin yield true rescue *exceptions => @rescued_exception false end end |
- (Boolean) matches?(actual)
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.
25 26 27 28 |
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 25 def matches?(actual) @actual = actual match(expected, actual) end |