class SuperDiff::RSpec::OperationTreeBuilders::HashIncluding

Public Class Methods

applies_to?(expected, actual) click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/hash_including.rb, line 5
def self.applies_to?(expected, actual)
  (
    SuperDiff::RSpec.a_hash_including_something?(expected) ||
    SuperDiff::RSpec.hash_including_something?(expected)
  ) && actual.is_a?(::Hash)
end
new(expected:, **rest) click to toggle source
Calls superclass method
# File lib/super_diff/rspec/operation_tree_builders/hash_including.rb, line 12
def initialize(expected:, **rest)
  hash = if SuperDiff::RSpec.a_hash_including_something?(expected)
           expected.expecteds.first
         else
           expected.instance_variable_get(:@expected)
         end
  super(expected: hash, **rest)
end

Private Instance Methods

should_add_noop_operation?(key) click to toggle source
# File lib/super_diff/rspec/operation_tree_builders/hash_including.rb, line 23
def should_add_noop_operation?(key)
  !expected.include?(key) || (
    actual.include?(key) &&
    expected[key] == actual[key]
  )
end