Module: Oselvar::Var::Core::DocStringDiffs

Defined in:
lib/oselvar/var/core/doc_string_diff.rb

Overview

Pure comparison of a doc-string step's return against the fence body. Port of doc-string-diff.ts.

Class Method Summary collapse

Class Method Details

.compare_doc_string(returned, content, span) ⇒ Object

nil → no check; equal string → nil (pass); unequal → DocStringDiff; non-string → ReturnShapeError.

Raises:



28
29
30
31
32
33
34
# File 'lib/oselvar/var/core/doc_string_diff.rb', line 28

def compare_doc_string(returned, content, span)
  return nil if returned.nil?
  raise ReturnShapeError, "expected a doc string (string), got #{returned.class}" unless returned.is_a?(String)
  return nil if returned == content

  DocStringDiff.new(span: span, expected: content, actual: returned)
end