Skip to content

Commit

Permalink
Remove pre-1.99 use of :context.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jan 13, 2016
1 parent bd0cea9 commit 76b7167
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lib/rdf/spec/enumerable.rb
Expand Up @@ -500,7 +500,7 @@
it {is_expected.to be_an_enumerator}
it {is_expected.to be_countable}
it "enumerates the same as #each_graph" do
expect(subject.to_a).to include(*enumerable.each_graph.to_a) if @supports_context # expect with match problematic
expect(subject.to_a).to include(*enumerable.each_graph.to_a) if @supports_named_graphs # expect with match problematic
end
end
end
Expand Down
38 changes: 1 addition & 37 deletions lib/rdf/spec/queryable.rb
Expand Up @@ -77,43 +77,7 @@
end
end

context "with context", unless: RDF::VERSION.to_s >= "1.99" do
it "returns statements from all contexts with no context" do
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: nil)
solutions = []
subject.send(method, pattern) {|s| solutions << s}
expect(solutions.size).to eq @statements.size
end

it "returns statements from unnamed contexts with false context" do
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: false)
solutions = []
subject.send(method, pattern) {|s| solutions << s}
context_statements = subject.statements.reject {|st| st.has_context?}.length
expect(solutions.size).to eq context_statements
end

it "returns statements from named contexts with variable context" do
unless subject.contexts.to_a.empty?
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: :c)
solutions = []
subject.send(method, pattern) {|s| solutions << s}
context_statements = subject.statements.select {|st| st.has_context?}.length
expect(solutions.size).to eq context_statements
end
end

it "returns statements from specific context with URI context" do
unless subject.contexts.to_a.empty?
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: RDF::URI("http://ar.to/#self"))
solutions = []
subject.send(method, pattern) {|s| solutions << s}
expect(solutions.size).to eq File.readlines(@doap).grep(/^<http:\/\/ar.to\/\#self>/).size
end
end
end

context "with graph_name", if: RDF::VERSION.to_s >= "1.99" do
context "with graph_name" do
it "returns statements from all graphs with no graph_name" do
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: nil)
solutions = []
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/spec/transaction.rb
Expand Up @@ -79,7 +79,7 @@
subject.execute(r)
end

context 'with graph names', if: RDF::VERSION.to_s >= "1.99" do
context 'with graph names' do
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
let(:s_with_c) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"), graph_name: RDF::URI('c_st'))}

Expand Down Expand Up @@ -135,7 +135,7 @@
end
end

context 'with graph names', if: RDF::VERSION.to_s >= "1.99" do
context 'with graph names' do
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
let(:s_with_c) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"), graph_name: RDF::URI('c_st'))}

Expand Down
18 changes: 1 addition & 17 deletions lib/rdf/spec/writable.rb
Expand Up @@ -114,23 +114,7 @@
end
end

it "should treat statements with a different context as distinct", unless: RDF::VERSION.to_s >= "1.99" do
if subject.writable?
s1 = statement.dup
s1.context = nil
s2 = statement.dup
s2.context = RDF::URI.new("urn:context:1")
s3 = statement.dup
s3.context = RDF::URI.new("urn:context:2")
subject.insert(s1)
subject.insert(s2)
subject.insert(s3)
# If contexts are not suported, all three are redundant
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
end
end

it "should treat statements with a different graph_name as distinct", if: RDF::VERSION.to_s >= "1.99" do
it "should treat statements with a different graph_name as distinct" do
if subject.writable?
s1 = statement.dup
s1.graph_name = nil
Expand Down

0 comments on commit 76b7167

Please sign in to comment.