Class: RSpec::Matchers::BuiltIn::HaveAttributes
- Inherits:
-
Object
- Object
- RSpec::Matchers::BuiltIn::HaveAttributes
- Includes:
- SuperDiff::RSpec::AugmentedMatcher
- Defined in:
- lib/super_diff/rspec/monkey_patches.rb
Instance Method Summary collapse
- #actual_has_attribute?(attribute_key, attribute_value) ⇒ Boolean
-
#cache_all_values ⇒ Object
Override this method to skip non-existent attributes, and to use public_send.
-
#respond_to_attributes? ⇒ Boolean
Override to force @values to get populated so that we can show a proper diff.
-
#respond_to_failure_message_or ⇒ Object
Override to not improve_hash_formatting.
Methods included from SuperDiff::RSpec::AugmentedMatcher
#description, #diffable?, #failure_message, #failure_message_when_negated
Instance Method Details
#actual_has_attribute?(attribute_key, attribute_value) ⇒ Boolean
539 540 541 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 539 def actual_has_attribute?(attribute_key, attribute_value) values_match?(attribute_value, @values.fetch(attribute_key)) end |
#cache_all_values ⇒ Object
Override this method to skip non-existent attributes, and to use public_send
528 529 530 531 532 533 534 535 536 537 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 528 def cache_all_values @values = @expected.keys.inject({}) do |hash, attribute_key| if @actual.respond_to?(attribute_key) actual_value = @actual.public_send(attribute_key) hash.merge(attribute_key => actual_value) else hash end end end |
#respond_to_attributes? ⇒ Boolean
Override to force @values to get populated so that we can show a proper diff
519 520 521 522 523 524 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 519 def respond_to_attributes? cache_all_values matches = respond_to_matcher.matches?(@actual) @respond_to_failed = !matches matches end |
#respond_to_failure_message_or ⇒ Object
Override to not improve_hash_formatting
544 545 546 547 548 549 550 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 544 def if respond_to_failed respond_to_matcher. else yield end end |