Skip to content

Commit

Permalink
Use #to_h instead of #to_hash. Test for DEPRECATION on uses of `#…
Browse files Browse the repository at this point in the history
…to_hash`. This is associated with ruby-rdf/rdf#333.
  • Loading branch information
gkellogg committed Dec 29, 2016
1 parent 98df11c commit 9647584
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.1.0
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
20 changes: 16 additions & 4 deletions lib/rdf/spec/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,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
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

0 comments on commit 9647584

Please sign in to comment.