Sha256: 6c55b349a25865baac4ed98cb4e9e04fa56e1b68b1539d9f26525f56714ff608

Contents?: true

Size: 906 Bytes

Versions: 1

Compression:

Stored size: 906 Bytes

Contents

RSpec::Matchers.define :be_same_as do |expected|
  match do |actual|
    actual.same_as?(expected)
  end

  failure_message do |actual|
   #%(#{actual.inspect_without_ignored_attributes} was expected to have the same attributes as\n) +
   #%(#{expected.inspect_without_ignored_attributes})

    attr_names_that_differed = actual.attributes_without_ignored_attributes.select do |k,v|
      expected[k] != v
    end.map(&:first)
    # TODO: pass extra option to inspect_with (such as the other object) so that it can use the same width for each attribute so that they line up nicely and are easy to visually compare
    %(expected: #{expected.inspect_with(attr_names_that_differed)}\n) +
    %(     got: #{actual.inspect_with(attr_names_that_differed)})
  end

  failure_message_when_negated do |actual|
    %(         expected: #{expected.inspect}\n) +
    %(to not be same_as: #{actual.inspect})
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_record_ignored_attributes-0.0.5 lib/active_record_ignored_attributes/matchers/be_same_as.rb