Skip to content

Commit 9647584

Browse files
committed
Use #to_h instead of #to_hash. Test for DEPRECATION on uses of #to_hash. This is associated with ruby-rdf/rdf#333.
1 parent 98df11c commit 9647584

5 files changed

Lines changed: 26 additions & 9 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.1.0

dependencyci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
platform:
2+
Rubygems:
3+
rdf-isomorphic:
4+
tests:
5+
unmaintained: skip

lib/rdf/spec/enumerable.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,23 @@
512512

513513

514514
context "when converting" do
515-
it {is_expected.to respond_to(:to_hash)}
516-
its(:to_hash) {is_expected.to be_instance_of(Hash)}
517-
context "#to_hash" do
515+
it {is_expected.to respond_to(:to_h)}
516+
it {is_expected.not_to respond_to(:to_hash)}
517+
its(:to_hash) {
518+
expect {
519+
is_expected.to be_instance_of(Hash)
520+
}.to write("DEPRECATION").to(:error)
521+
}
522+
describe "#to_h" do
518523
it "should have as many keys as subjects" do
519-
expect(subject.to_hash.keys.size).to eq enumerable.subjects.to_a.size
524+
expect(subject.to_h.keys.size).to eq enumerable.subjects.to_a.size
525+
end
526+
end
527+
describe "#to_h" do
528+
it "should have as many keys as subjects (with deprecation)" do
529+
expect {
530+
expect(subject.to_hash.keys.size).to eq enumerable.subjects.to_a.size
531+
}.to write("DEPRECATION").to(:error)
520532
end
521533
end
522534
end

lib/rdf/spec/mutable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
it 'handles Graph names' do
263263
if @supports_named_graphs
264264
dels = non_bnode_statements.take(10).map do |st|
265-
RDF::Statement.from(st.to_hash.merge(graph_name: RDF::URI('http://example.com/fake')))
265+
RDF::Statement.from(st.to_h.merge(graph_name: RDF::URI('http://example.com/fake')))
266266
end
267267
dels.map! { |st| st.graph_name = RDF::URI('http://example.com/fake'); st }
268268
dels.extend(RDF::Enumerable)

lib/rdf/spec/writable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@
126126
end
127127

128128
it "should not insert an incomplete statement" do
129-
expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(subject: nil)))}.to raise_error(ArgumentError)
130-
expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(predicate: nil)))}.to raise_error(ArgumentError)
131-
expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(object: nil)))}.to raise_error(ArgumentError)
129+
expect {subject.insert(RDF::Statement.from(statement.to_h.merge(subject: nil)))}.to raise_error(ArgumentError)
130+
expect {subject.insert(RDF::Statement.from(statement.to_h.merge(predicate: nil)))}.to raise_error(ArgumentError)
131+
expect {subject.insert(RDF::Statement.from(statement.to_h.merge(object: nil)))}.to raise_error(ArgumentError)
132132
expect(subject.count).to eql 0
133133
end
134134

0 commit comments

Comments
 (0)