Class: RSpec::ActiveRecord::DiffForMultipleRecords Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/active_record/diff_for_multiple_records.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(attributes, records) ⇒ DiffForMultipleRecords

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DiffForMultipleRecords.



7
8
9
10
# File 'lib/rspec/active_record/diff_for_multiple_records.rb', line 7

def initialize(attributes, records)
  @attributes = attributes
  @records = records
end

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
# File 'lib/rspec/active_record/diff_for_multiple_records.rb', line 12

def call
  @records.map do |record|
    record_attributes = @attributes.keys.index_with { |key| record.__send__(key) }
    diff = RSpec::Expectations.differ.diff(record_attributes, @attributes)
    "Diff for #{record.class.name}##{record.id}\n#{diff}"
  end.join("\n\n")
end