class SuperDiff::RSpec::OperationTreeBuilders::ObjectHavingAttributes
Public Class Methods
applies_to?(expected, _actual)
click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb, line 5 def self.applies_to?(expected, _actual) SuperDiff::RSpec.an_object_having_some_attributes?(expected) end
Protected Instance Methods
attribute_names()
click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb, line 15 def attribute_names if actual.respond_to?(:attributes_for_super_diff) actual.attributes_for_super_diff.keys | expected.expected.keys else expected.expected.keys end end
build_operation_tree()
click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb, line 11 def build_operation_tree find_operation_tree_for(actual) end
Private Instance Methods
establish_expected_and_actual_attributes()
click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb, line 25 def establish_expected_and_actual_attributes @expected_attributes = attribute_names.reduce({}) do |hash, name| if expected.expected.include?(name) hash.merge(name => expected.expected[name]) else hash end end @actual_attributes = attribute_names.reduce({}) do |hash, name| if actual.respond_to?(name) hash.merge(name => actual.public_send(name)) else hash end end end
should_add_insert_operation?(attribute_name)
click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb, line 50 def should_add_insert_operation?(attribute_name) expected_attributes.include?(attribute_name) && actual_attributes.include?(attribute_name) && expected_attributes[attribute_name] != actual_attributes[attribute_name] end
should_add_noop_operation?(attribute_name)
click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb, line 43 def should_add_noop_operation?(attribute_name) !expected_attributes.include?(attribute_name) || ( actual_attributes.include?(attribute_name) && expected_attributes[attribute_name] == actual_attributes[attribute_name] ) end