Skip to content

Commit 262ebf0

Browse files
Arthur Dingemansgkellogg
authored andcommitted
Fix the graph passed to new terms
It always passed the RDF::Vocabulary class instead of the actual vocab
1 parent d22e026 commit 262ebf0

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/rdf/vocabulary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def initialize(uri)
731731
# @param [#to_s] property
732732
# @return [URI]
733733
def [](property)
734-
Term.intern([to_s, property.to_s].join(''), vocab: self.class, attributes: {})
734+
Term.intern([to_s, property.to_s].join(''), vocab: self, attributes: {})
735735
end
736736

737737
##

spec/vocabulary_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,31 @@
1616
it "should allow method_missing" do
1717
expect {subject.foo}.not_to raise_error
1818
expect(subject.foo).to be_a(RDF::Vocabulary::Term)
19+
expect(subject.foo.vocab.to_s).to eq('http://example.org/')
1920
end
2021

2122
it "camelizes on method_missing" do
2223
expect(subject.foo_bar).to be_a(RDF::Vocabulary::Term)
2324
expect(subject.foo_bar).to eq (subject.to_uri / 'fooBar')
25+
expect(subject.foo_bar.vocab.to_s).to eq('http://example.org/')
2426
end
2527

2628
it "should allow []" do
2729
expect {subject["foo"]}.not_to raise_error
2830
expect(subject["foo"]).to be_a(RDF::Vocabulary::Term)
31+
expect(subject["foo"].vocab.to_s).to eq('http://example.org/')
2932
end
3033

3134
it "allows #send" do
3235
expect {subject.send(:foo)}.not_to raise_error
3336
expect(subject.send(:foo)).to be_a(RDF::Vocabulary::Term)
37+
expect(subject.send(:foo).vocab.to_s).to eq('http://example.org/')
3438
end
3539

3640
it "allows #public_send" do
3741
expect {subject.public_send(:foo)}.not_to raise_error
3842
expect(subject.public_send(:foo)).to be_a(RDF::Vocabulary::Term)
43+
expect(subject.public_send(:foo).vocab.to_s).to eq('http://example.org/')
3944
end
4045

4146
it "does not add to @@uris" do

0 commit comments

Comments
 (0)