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
525 526 527 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 525 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
514 515 516 517 518 519 520 521 522 523 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 514 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
505 506 507 508 509 510 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 505 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
530 531 532 533 534 535 536 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 530 def if respond_to_failed respond_to_matcher. else yield end end |