migrants/spec/example_01_spec.rb

24 lines
792 B
Ruby

require 'rdf'
require 'rdf/turtle'
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(:full_graph) do
graph = RDF::Graph.new
Dir.glob(File.join(data_dir, '*.ttl')).each do |path|
graph.load(path)
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| " #{s.to_ntriples}" }.join("\n")
end
end