Skip to content

Commit 9be73ce

Browse files
author
Tom Johnson
committed
Relax testing of graph handing in Queryable specs
`Queryable` shared examples failed for `Graph`s with a non-default graph name. They required the graph to retain the query pattern's `graph_name`, which is undesirable behavior. Instead `Graph` replaces the provided `graph_name` with its own, when querying, mimicking its behavior on write operations. This relaxes the specs to allow for the special case of a queryable scoped in this way.
1 parent 4af8ed5 commit 9be73ce

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

lib/rdf/spec/queryable.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,27 @@
8989
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: false)
9090
solutions = []
9191
subject.send(method, pattern) {|s| solutions << s}
92-
named_statements = subject.statements.reject {|st| st.has_name?}.length
93-
expect(solutions.size).to eq named_statements
92+
93+
named_statements = subject.statements
94+
named_statements.reject! {|st| st.has_name?} unless
95+
subject.respond_to?(:graph_name) && !subject.graph_name.nil?
96+
97+
expect(solutions.size).to eq named_statements.size
9498
end
9599

96-
it "returns statements from named graphss with variable graph_name" do
100+
it "returns statements from named graphs with variable graph_name" do
97101
unless subject.graph_names.to_a.empty?
98102
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: :c)
99103
solutions = []
100104
subject.send(method, pattern) {|s| solutions << s}
101-
named_statements = subject.statements.select {|st| st.has_name?}.length
102-
expect(solutions.size).to eq named_statements
105+
named_statements = subject.statements.select {|st| st.has_name?}
106+
expect(solutions.size).to eq named_statements.size
103107
end
104108
end
105109

106110
it "returns statements from specific graph with URI graph_name" do
107-
unless subject.graph_names.to_a.empty?
111+
unless subject.graph_names.to_a.empty? ||
112+
(subject.respond_to?(:graph_name) && !subject.graph_name.nil?)
108113
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: RDF::URI("http://ar.to/#self"))
109114
solutions = []
110115
subject.send(method, pattern) {|s| solutions << s}

0 commit comments

Comments
 (0)