class RoadForest::Testing::BeEquivalentGraph
Constants
- Info
Attributes
expected[R]
info[R]
Public Class Methods
new(expected, info)
click to toggle source
# File lib/roadforest/test-support/matchers.rb, line 56 def initialize(expected, info) @expected = normalize(expected) @info = if info.respond_to?(:about) info elsif info.is_a?(Hash) identifier = expected.is_a?(RDF::Graph) ? expected.context : info[:about] trace = info[:trace] trace = trace.join("\n") if trace.is_a?(Array) i = Info.new(identifier, "0000", trace, info[:compare]) i.format = info[:format] i else Info.new(expected.is_a?(RDF::Graph) ? expected.context : info, "0000", info.to_s) end @info.format ||= :ttl end
Public Instance Methods
description()
click to toggle source
# File lib/roadforest/test-support/matchers.rb, line 92 def description "be equivalent to an expected graph" #graphs tend to be too long to use end
dump_graph(graph)
click to toggle source
# File lib/roadforest/test-support/matchers.rb, line 82 def dump_graph(graph) graph.dump(@info.format, :standard_prefixes => true) rescue begin graph.dump(:nquads, :standard_prefixes => true) rescue graph.inspect end end
failure_message_for_should()
click to toggle source
# File lib/roadforest/test-support/matchers.rb, line 96 def failure_message_for_should info = @info.respond_to?(:about) ? @info.about : @info.inspect if @expected.is_a?(RDF::Graph) && @actual.size != @expected.size "Graph entry count differs:\nexpected: #{@expected.size}\nactual: #{@actual.size}" elsif @expected.is_a?(Array) && @actual.size != @expected.length "Graph entry count differs:\nexpected: #{@expected.length}\nactual: #{@actual.size}" else "Graph differs" end + "\n#{info + "\n" unless info.to_s.empty?}" + (@info.inputDocument ? "Input file: #{@info.inputDocument}\n" : "") + (@info.outputDocument ? "Output file: #{@info.outputDocument}\n" : "") + "\nExpected:\n#{dump_graph(@expected)}" + "\nResults:\n#{dump_graph(@actual)}" + (@info.trace ? "\nDebug:\n#{@info.trace}" : "") end
matches?(actual)
click to toggle source
# File lib/roadforest/test-support/matchers.rb, line 77 def matches?(actual) @actual = normalize(actual) @actual.isomorphic_with?(@expected)# rescue false end