Skip to content

Commit

Permalink
Fix issue with multiple sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed May 10, 2022
1 parent 7fa5bcf commit 559d5a0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rdf/aggregate_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ def default_graph
# Otherwise, create a MergeGraph from the set of pairs of source and graph_name
RDF::MergeGraph.new(name: nil) do |graph|
if defaults == [false]
graph.sources.each do |s|
sources.each do |s|
# Add default graph from each source
source s, false
graph.source s, false
end
else
defaults.each do |graph_name|
Expand Down
27 changes: 27 additions & 0 deletions spec/aggregate_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@
include_examples "AggregateRepo", @dataset
end

context "multiple sources" do
let(:r1) {RDF::Repository.new {|r| r << RDF::Statement(RDF::URI('s1'), RDF::URI('p1'), "o1")}}
let(:r2) {RDF::Repository.new {|r| r << RDF::Statement(RDF::URI('s2'), RDF::URI('p2'), "o2", graph_name: RDF::URI('g1'))}}
before(:each) do
@dataset = RDF::AggregateRepo.new(r1, r2) do
default false
named RDF::URI('g1')
end
end
subject {@dataset}

it {is_expected.not_to be_empty}
its(:count) {is_expected.to eql 2}
its(:graph_names) {is_expected.to include(*@dataset.graph_names)}
describe "#default_graph" do
subject {@dataset.default_graph}
its(:count) {is_expected.to eql 1}
it "statements have no graph_name" do
expect(subject.statements.map(&:graph_name)).to all(be_nil)
end
end
describe "#enum_graph" do
subject {@dataset.enum_graph}
its(:count) {is_expected.to eql 2}
end
end

context "with specific named entities" do
let(:repo) {RDF::Repository.new {|r| RDF::Spec.quads.each {|s| r << s}}}
let(:gkellogg) {RDF::Graph(graph_name: "https://greggkellogg.net/foaf#me", data: repo)}
Expand Down

0 comments on commit 559d5a0

Please sign in to comment.