diff --git a/.travis.yml b/.travis.yml index 3d5c433..f5b20ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,14 @@ script: "bundle exec rspec spec" env: - CI=true rvm: - - 2.0 - - 2.1 - - 2.2.4 - - 2.3.0 - - jruby-9.0.4.0 - - rbx-2 + - 2.2.6 + - 2.3.3 + - 2.4.0 + - jruby + - rbx cache: bundler sudo: false matrix: allow_failures: - - rvm: rbx-2 + - rvm: rbx + - rvm: jruby diff --git a/Gemfile b/Gemfile index cf8b9a2..a78d207 100644 --- a/Gemfile +++ b/Gemfile @@ -5,10 +5,6 @@ gemspec gem 'rdf', github: "ruby-rdf/rdf", branch: "develop" gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop" -group :development do - gem "wirble" -end - group :debug do gem "byebug", platform: :mri end diff --git a/README.md b/README.md index b7587fc..5361fe3 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ Note that in most cases, if the instance is empty and mutable, the appropriate s ## Dependencies -* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.1) -* [RSpec](http://rubygems.org/gems/rspec) (>= 2.1.0) +* [RDF.rb](http://rubygems.org/gems/rdf) (~> 2.0) +* [RSpec](http://rubygems.org/gems/rspec) (~> 3.0) ## Installation diff --git a/VERSION b/VERSION index 227cea2..a1bba89 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 +2.2.0-rc1 diff --git a/dependencyci.yml b/dependencyci.yml new file mode 100644 index 0000000..0c67c1b --- /dev/null +++ b/dependencyci.yml @@ -0,0 +1,5 @@ +platform: + Rubygems: + rdf-isomorphic: + tests: + unmaintained: skip \ No newline at end of file diff --git a/lib/rdf/spec/enumerable.rb b/lib/rdf/spec/enumerable.rb index 8be1a08..4cf0d37 100644 --- a/lib/rdf/spec/enumerable.rb +++ b/lib/rdf/spec/enumerable.rb @@ -391,11 +391,16 @@ its(:each_term) {is_expected.to be_an_enumerator} context "#each_term" do - specify { - expect(subject.each_term.reject(&:node?).size).to eq non_bnode_terms.length - } - specify {expect(subject.each_term).to all(be_a_term)} - specify {subject.each_term {|value| expect(non_bnode_terms).to include(value) unless value.node?}} + it 'has correct number of terms' do + expected_count = non_bnode_terms.length + expected_count = expected_count - 3 unless + subject.supports?(:literal_equality) + + expect(subject.each_term.reject(&:node?).size).to eq expected_count + end + + specify { expect(subject.each_term).to all(be_a_term) } + specify { subject.each_term {|value| expect(non_bnode_terms).to include(value) unless value.node?} } end its(:enum_term) {is_expected.to be_an_enumerator} @@ -507,11 +512,23 @@ context "when converting" do - it {is_expected.to respond_to(:to_hash)} - its(:to_hash) {is_expected.to be_instance_of(Hash)} - context "#to_hash" do + it {is_expected.to respond_to(:to_h)} + it {is_expected.not_to respond_to(:to_hash)} + its(:to_hash) { + expect { + is_expected.to be_instance_of(Hash) + }.to write("DEPRECATION").to(:error) + } + describe "#to_h" do it "should have as many keys as subjects" do - expect(subject.to_hash.keys.size).to eq enumerable.subjects.to_a.size + expect(subject.to_h.keys.size).to eq enumerable.subjects.to_a.size + end + end + describe "#to_h" do + it "should have as many keys as subjects (with deprecation)" do + expect { + expect(subject.to_hash.keys.size).to eq enumerable.subjects.to_a.size + }.to write("DEPRECATION").to(:error) end end end diff --git a/lib/rdf/spec/mutable.rb b/lib/rdf/spec/mutable.rb index 72d38d7..1611a73 100644 --- a/lib/rdf/spec/mutable.rb +++ b/lib/rdf/spec/mutable.rb @@ -262,7 +262,7 @@ it 'handles Graph names' do if @supports_named_graphs dels = non_bnode_statements.take(10).map do |st| - RDF::Statement.from(st.to_hash.merge(graph_name: RDF::URI('http://example.com/fake'))) + RDF::Statement.from(st.to_h.merge(graph_name: RDF::URI('http://example.com/fake'))) end dels.map! { |st| st.graph_name = RDF::URI('http://example.com/fake'); st } dels.extend(RDF::Enumerable) diff --git a/lib/rdf/spec/queryable.rb b/lib/rdf/spec/queryable.rb index 76954fc..510bc56 100644 --- a/lib/rdf/spec/queryable.rb +++ b/lib/rdf/spec/queryable.rb @@ -60,18 +60,31 @@ context "with specific patterns" do # Note that "01" should not match 1, per data-r2/expr-equal/sameTerm - { - [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], - [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), nil] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], - [RDF::URI("http://example.org/xi1"), nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], - [nil, RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], - [nil, nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], - [nil, RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")] => [RDF::Statement.from([RDF::URI("http://example.org/xd1"), RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")])], - }.each do |pattern, result| - pattern = RDF::Query::Pattern.from(pattern) + patterns = + { [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], + [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), nil] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], + [RDF::URI("http://example.org/xi1"), nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], + [nil, RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], + [nil, nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], + [nil, RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")] => [RDF::Statement.from([RDF::URI("http://example.org/xd1"), RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")])], + } + + literal_eq_patterns = + [[nil, RDF::URI("http://example.org/p"), 1], + [nil, nil, 1], + [nil, RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")]] + + patterns.each do |pattern, result| it "returns #{result.inspect} given #{pattern.inspect}" do + unless subject.supports?(:literal_equality) + next if literal_eq_patterns.include?(pattern) + end + + pattern = RDF::Query::Pattern.from(pattern) solutions = [] + subject.send(method, pattern) {|s| solutions << s} + expect(solutions).to contain_exactly(*result) end end @@ -85,18 +98,6 @@ expect(solutions.size).to eq @statements.size end - it "returns statements from unnamed graphs with false graph_name" do - pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: false) - solutions = [] - subject.send(method, pattern) {|s| solutions << s} - - named_statements = subject.statements - named_statements.reject! {|st| st.has_name?} unless - subject.respond_to?(:graph_name) && !subject.graph_name.nil? - - expect(solutions.size).to eq named_statements.size - end - it "returns statements from named graphs with variable graph_name" do unless subject.graph_names.to_a.empty? pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: :c) @@ -276,7 +277,9 @@ end it 'has two solutions' do - expect(result.count).to eq 2 + if subject.supports?(:literal_equality) + expect(result.count).to eq 2 + end end it "has xi1 as a solution" do @@ -296,7 +299,9 @@ end it 'has one solution' do - expect(result.count).to eq 1 + if subject.supports?(:literal_equality) + expect(result.count).to eq 1 + end end it "has xd1 as a solution" do @@ -314,8 +319,7 @@ before { skip unless subject.respond_to?(:query_execute, true ) } it "defines a protected #query_execute method" do - expect(subject.class.protected_method_defined?(:query_execute)) - .to be_truthy + expect(subject.protected_methods).to include :query_execute end include_examples 'query execution', :query_execute @@ -327,7 +331,7 @@ before { skip unless subject.respond_to?(:query_pattern, true ) } it "defines a protected #query_pattern method" do - expect(subject.class.protected_method_defined?(:query_pattern)).to be_truthy + expect(subject.protected_methods).to include :query_pattern end include_examples 'query pattern', :query_pattern diff --git a/lib/rdf/spec/repository.rb b/lib/rdf/spec/repository.rb index 717693c..fbedb16 100644 --- a/lib/rdf/spec/repository.rb +++ b/lib/rdf/spec/repository.rb @@ -48,35 +48,6 @@ end end - describe "#transaction" do - it 'gives an immutable transaction' do - expect { subject.transaction { insert([]) } }.to raise_error TypeError - end - - it 'commits a successful transaction' do - statement = RDF::Statement(:s, RDF.type, :o) - expect(subject).to receive(:commit_transaction).and_call_original - - expect do - subject.transaction(mutable: true) { insert(statement) } - end.to change { subject.statements }.to include(statement) - end - - it 'rolls back a failed transaction' do - original_contents = subject.statements - expect(subject).to receive(:rollback_transaction).and_call_original - - expect do - subject.transaction(mutable: true) do - delete(*@statements) - raise 'my error' - end - end.to raise_error RuntimeError - - expect(subject.statements).to contain_exactly(*original_contents) - end - end - context "with snapshot support" do describe '#snapshot' do diff --git a/lib/rdf/spec/transactable.rb b/lib/rdf/spec/transactable.rb index dc5ca5c..8d2a35b 100644 --- a/lib/rdf/spec/transactable.rb +++ b/lib/rdf/spec/transactable.rb @@ -18,7 +18,9 @@ end it 'commits a successful transaction' do - statement = RDF::Statement(:s, RDF.type, :o) + statement = RDF::Statement(RDF::URI('http://example.com/s'), + RDF.type, + RDF::URI('http://example.com/o')) expect(subject).to receive(:commit_transaction).and_call_original expect do diff --git a/lib/rdf/spec/transaction.rb b/lib/rdf/spec/transaction.rb index 8be8e32..ef9ca0f 100644 --- a/lib/rdf/spec/transaction.rb +++ b/lib/rdf/spec/transaction.rb @@ -250,6 +250,26 @@ end end + describe '#mutated?' do + let(:st) { RDF::Statement(:s, RDF::URI('http://example.com/p'), 'o') } + + it 'returns true after a successful insert' do + begin + expect { subject.insert(st) } + .to change { subject.mutated? }.from(false).to(true) + rescue NotImplementedError; end + end + + it 'returns true after a successful delete' do + repository.insert(st) + + begin + expect { subject.delete(st) } + .to change { subject.mutated? }.from(false).to(true) + rescue NotImplementedError; end + end + end + describe '#execute' do let(:st) { RDF::Statement(:s, RDF::URI('http://example.com/p'), 'o') } diff --git a/lib/rdf/spec/writable.rb b/lib/rdf/spec/writable.rb index fc3c6f5..f111dc1 100644 --- a/lib/rdf/spec/writable.rb +++ b/lib/rdf/spec/writable.rb @@ -126,9 +126,9 @@ end it "should not insert an incomplete statement" do - expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(subject: nil)))}.to raise_error(ArgumentError) - expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(predicate: nil)))}.to raise_error(ArgumentError) - expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(object: nil)))}.to raise_error(ArgumentError) + expect {subject.insert(RDF::Statement.from(statement.to_h.merge(subject: nil)))}.to raise_error(ArgumentError) + expect {subject.insert(RDF::Statement.from(statement.to_h.merge(predicate: nil)))}.to raise_error(ArgumentError) + expect {subject.insert(RDF::Statement.from(statement.to_h.merge(object: nil)))}.to raise_error(ArgumentError) expect(subject.count).to eql 0 end diff --git a/rdf-spec.gemspec b/rdf-spec.gemspec index 8d765e6..0814d07 100755 --- a/rdf-spec.gemspec +++ b/rdf-spec.gemspec @@ -25,13 +25,13 @@ Gem::Specification.new do |gem| gem.test_files = %w() gem.has_rdoc = false - gem.required_ruby_version = '>= 2.0' + gem.required_ruby_version = '>= 2.2.2' gem.requirements = [] - gem.add_runtime_dependency 'rdf', '~> 2.0' + gem.add_runtime_dependency 'rdf', '~> 2.1' gem.add_runtime_dependency 'rdf-isomorphic', '~> 2.0' - gem.add_runtime_dependency 'rspec', '~> 3.0' + gem.add_runtime_dependency 'rspec', '~> 3.5' gem.add_runtime_dependency 'rspec-its', '~> 1.0' - gem.add_runtime_dependency 'webmock', '~> 1.17' + gem.add_runtime_dependency 'webmock', '~> 2.3' gem.add_development_dependency 'yard' , '~> 0.8' gem.post_install_message = nil end