Skip to content

Commit

Permalink
Finish 2.2.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 31, 2016
2 parents 0eefc91 + c8bf756 commit 5069156
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 87 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.2.0-rc1
5 changes: 5 additions & 0 deletions dependencyci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
platform:
Rubygems:
rdf-isomorphic:
tests:
unmaintained: skip
35 changes: 26 additions & 9 deletions lib/rdf/spec/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/spec/mutable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
56 changes: 30 additions & 26 deletions lib/rdf/spec/queryable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
29 changes: 0 additions & 29 deletions lib/rdf/spec/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/rdf/spec/transactable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions lib/rdf/spec/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }

Expand Down
6 changes: 3 additions & 3 deletions lib/rdf/spec/writable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions rdf-spec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5069156

Please sign in to comment.