Class: RSpec::Snapshot::DefaultSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/snapshot/default_serializer.rb

Overview

Serializes values in a human readable way for snapshots using the amazing_print gem (or awesome_print for backward compatibility)

Instance Method Summary collapse

Instance Method Details

#dump(value) ⇒ String

Returns The serialized value.

Parameters:

  • value (*) —

    The value to serialize.

Returns:

  • (String) —

    The serialized value.



18
19
20
21
22
23
24
25
26
27
# File 'lib/rspec/snapshot/default_serializer.rb', line 18

def dump(value)
  output = value.ai(plain: true, indent: 2)

  # Convert modern syntax to classic syntax for backward compatibility
  if use_classic_syntax? && PRINT_GEM == :amazing_print
    output = convert_to_classic_syntax(output)
  end

  output
end