Skip to content

Commit c9d4e7f

Browse files
committed
Add failure_message_when_negated for be_equivalent_graph.
1 parent 3580169 commit c9d4e7f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/rdf/spec/matchers.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,19 @@ def normalize(graph)
314314
"Results:\n#{@actual.dump(format, standard_prefixes: true, literal_shorthand: false, validate: false) rescue @actual.inspect}" +
315315
"\nDebug:\n#{@info.logger}"
316316
end
317+
318+
failure_message_when_negated do |actual|
319+
format = case
320+
when RDF.const_defined?(:TriG) then :trig
321+
when RDF.const_defined?(:Turtle) then :ttl
322+
else :nquads
323+
end
324+
info = @info.respond_to?(:information) ? @info.information : @info.inspect
325+
"Graphs identical\n" +
326+
"\n#{info + "\n" unless info.empty?}" +
327+
"Results:\n#{actual.dump(format, standard_prefixes: true, literal_shorthand: false, validate: false) rescue @actual.inspect}" +
328+
"\nDebug:\n#{@info.logger}"
329+
end
317330
end
318331

319332
require 'json'
@@ -347,6 +360,15 @@ def normalize(graph)
347360
"\n#{info + "\n" unless info.empty?}" +
348361
"\nDebug:\n#{@info.logger}"
349362
end
363+
364+
failure_message_when_negated do |actual|
365+
info = @info.respond_to?(:information) ? @info.information : @info.inspect
366+
367+
"Expected not to produce the following:\n" +
368+
"Actual : #{actual.is_a?(String) ? actual : actual.to_json(JSON_STATE) rescue 'malformed json'}\n" +
369+
"\n#{info + "\n" unless info.empty?}" +
370+
"\nDebug:\n#{@info.logger}"
371+
end
350372
end
351373

352374
end # Matchers

0 commit comments

Comments
 (0)