require 'rdf' require 'rdf/turtle' require 'rdf/ntriples' require 'logger' RSpec.describe 'data_examples/example_01.ttl' do let(:data_dir) { File.expand_path('../data', __dir__) } let(:example_file) { File.expand_path('../data_examples/example_01.ttl', __dir__) } let(:null_logger) { Logger.new(File::NULL) } let(:full_graph) do graph = RDF::Graph.new Dir.glob(File.join(data_dir, '*.ttl')).sort.each do |path| graph.load(path, logger: null_logger) end graph end let(:example_graph) { RDF::Graph.load(example_file) } it 'every triple in the example is present in the combined data graph' do missing = example_graph.each_statement.reject { |stmt| full_graph.include?(stmt) } expect(missing).to be_empty, "#{missing.size} triple(s) from the example are not in the data graph:\n" + missing.map { |s| " " + RDF::NTriples::Writer.serialize(s) }.join end end