Method: EqJsonMessageGenerator#generateExpectedItemNotFoundInArray

Defined in:
lib/message_generator.rb

#generateExpectedItemNotFoundInArray(expected_item, expected_count, actual_count) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/message_generator.rb', line 138

def generateExpectedItemNotFoundInArray(expected_item, expected_count, actual_count)
  # if @matcher.currentActualObj.nil?
  #    objectsNotInExpected = getObjectsNotInArray(@matcher.actual, @matcher.expected);
  #    objectsNotInActual = getObjectsNotInArray(@matcher.expected, @matcher.actual);
  # else
  #    objectsNotInExpected = getObjectsNotIn(@matcher.currentActualObj, @matcher.currentExpectedObj);
  #    objectsNotInActual = getObjectsNotIn(@matcher.currentExpectedObj, @matcher.currentActualObj);
  # end

  if actual_count == 0
    jsonErrorInfo = "JSON path #{@matcher.jsonPath}[] could not find:\n" +
        "#{expected_item.to_json}\n" +
        "in actual\n"
  else
    jsonErrorInfo = "JSON path #{@matcher.jsonPath}[] wrong number of:\n" +
        "#{expected_item.to_json}\n" +
        "in actual\n" +
        "expected: #{expected_count}\n" +
        @colorizer.green("     got: #{actual_count}") + "\n"
  end

  # unless objectsNotInExpected.empty?
  #   jsonErrorInfo << "expected does not contain #{objectsNotInExpected.to_json}\n"
  # end
  #
  # unless objectsNotInActual.empty?
  #   jsonErrorInfo << @colorizer.green("actual does not contain #{objectsNotInActual.to_json}\n")
  # end

  return getExpectedActualJson() + "\n" +
      "\nDiff:\n" +
      jsonErrorInfo
end