Class: RSpec::Matchers::BuiltIn::HaveAttributes Private
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::HaveAttributes
- Defined in:
- lib/rspec/matchers/built_in/have_attributes.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.
Provides the implementation for have_attributes
.
Not intended to be instantiated directly.
Constant Summary
Constants inherited from BaseMatcher
Instance Method Summary collapse
- #description ⇒ String private
- #diffable? ⇒ Boolean private
- #does_not_match?(actual) ⇒ Boolean private
- #failure_message ⇒ String private
- #failure_message_when_negated ⇒ String private
-
#initialize(expected) ⇒ HaveAttributes
constructor
private
A new instance of HaveAttributes.
- #matches?(actual) ⇒ Boolean private
Methods inherited from BaseMatcher
#expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?
Methods included from Composable
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
Constructor Details
#initialize(expected) ⇒ HaveAttributes
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 HaveAttributes.
11 12 13 14 15 16 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 11 def initialize(expected) @expected = expected @values = {} @respond_to_failed = false @negated = false end |
Instance Method Details
#description ⇒ 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.
43 44 45 46 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 43 def description described_items = surface_descriptions_in(expected) improve_hash_formatting "have attributes #{RSpec::Support::ObjectFormatter.format(described_items)}" end |
#diffable? ⇒ Boolean
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/have_attributes.rb', line 50 def diffable? !@respond_to_failed && !@negated end |
#does_not_match?(actual) ⇒ Boolean
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.
34 35 36 37 38 39 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 34 def does_not_match?(actual) @actual = actual @negated = true return false unless respond_to_attributes? perform_match(:none?) end |
#failure_message ⇒ 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.
56 57 58 59 60 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 56 def do "expected #{actual_formatted} to #{description} but had attributes #{ formatted_values }" end end |
#failure_message_when_negated ⇒ 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.
64 65 66 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 64 def { "expected #{actual_formatted} not to #{description}" } end |
#matches?(actual) ⇒ Boolean
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 29 30 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 25 def matches?(actual) @actual = actual @negated = false return false unless respond_to_attributes? perform_match(:all?) end |