active-triples 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -9
  3. data/CHANGES.md +69 -0
  4. data/Gemfile +0 -2
  5. data/Guardfile +1 -2
  6. data/active-triples.gemspec +3 -3
  7. data/lib/active/triples.rb +1 -0
  8. data/lib/active_triples.rb +4 -0
  9. data/lib/active_triples/configurable.rb +3 -1
  10. data/lib/active_triples/configuration.rb +1 -0
  11. data/lib/active_triples/configuration/item.rb +1 -0
  12. data/lib/active_triples/configuration/item_factory.rb +1 -0
  13. data/lib/active_triples/configuration/merge_item.rb +5 -2
  14. data/lib/active_triples/extension_strategy.rb +1 -0
  15. data/lib/active_triples/identifiable.rb +1 -0
  16. data/lib/active_triples/list.rb +2 -0
  17. data/lib/active_triples/nested_attributes.rb +1 -1
  18. data/lib/active_triples/node_config.rb +5 -3
  19. data/lib/active_triples/persistable.rb +1 -0
  20. data/lib/active_triples/persistence_strategies/parent_strategy.rb +104 -29
  21. data/lib/active_triples/persistence_strategies/persistence_strategy.rb +15 -7
  22. data/lib/active_triples/persistence_strategies/repository_strategy.rb +26 -22
  23. data/lib/active_triples/properties.rb +84 -6
  24. data/lib/active_triples/property.rb +35 -4
  25. data/lib/active_triples/property_builder.rb +38 -4
  26. data/lib/active_triples/rdf_source.rb +225 -75
  27. data/lib/active_triples/reflection.rb +42 -3
  28. data/lib/active_triples/relation.rb +330 -73
  29. data/lib/active_triples/repositories.rb +4 -2
  30. data/lib/active_triples/resource.rb +1 -0
  31. data/lib/active_triples/schema.rb +1 -0
  32. data/lib/active_triples/undefined_property_error.rb +27 -0
  33. data/lib/active_triples/version.rb +2 -1
  34. data/spec/active_triples/configurable_spec.rb +3 -2
  35. data/spec/active_triples/configuration_spec.rb +2 -1
  36. data/spec/active_triples/extension_strategy_spec.rb +2 -1
  37. data/spec/active_triples/identifiable_spec.rb +7 -11
  38. data/spec/active_triples/list_spec.rb +1 -4
  39. data/spec/active_triples/nested_attributes_spec.rb +4 -3
  40. data/spec/active_triples/persistable_spec.rb +4 -1
  41. data/spec/active_triples/persistence_strategies/parent_strategy_spec.rb +141 -11
  42. data/spec/active_triples/persistence_strategies/persistence_strategy_spec.rb +1 -0
  43. data/spec/active_triples/persistence_strategies/repository_strategy_spec.rb +32 -17
  44. data/spec/active_triples/properties_spec.rb +68 -33
  45. data/spec/active_triples/property_builder_spec.rb +36 -0
  46. data/spec/active_triples/property_spec.rb +15 -1
  47. data/spec/active_triples/rdf_source_spec.rb +544 -6
  48. data/spec/active_triples/reflection_spec.rb +78 -0
  49. data/spec/active_triples/relation_spec.rb +505 -3
  50. data/spec/active_triples/repositories_spec.rb +3 -1
  51. data/spec/active_triples/resource_spec.rb +90 -147
  52. data/spec/active_triples/schema_spec.rb +3 -2
  53. data/spec/active_triples_spec.rb +1 -0
  54. data/spec/integration/dummies/dummy_resource_a.rb +6 -0
  55. data/spec/integration/dummies/dummy_resource_b.rb +6 -0
  56. data/spec/integration/parent_persistence_spec.rb +18 -0
  57. data/spec/integration/reciprocal_properties_spec.rb +69 -0
  58. data/spec/pragmatic_context_spec.rb +10 -8
  59. data/spec/spec_helper.rb +5 -0
  60. data/spec/support/active_model_lint.rb +4 -6
  61. data/spec/support/dummies/basic_persistable.rb +2 -11
  62. data/spec/support/matchers.rb +11 -0
  63. data/spec/support/shared_examples/persistence_strategy.rb +3 -16
  64. metadata +20 -13
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
  describe ActiveTriples::Repositories do
3
4
  subject { ActiveTriples::Repositories }
@@ -15,7 +16,8 @@ describe ActiveTriples::Repositories do
15
16
  end
16
17
 
17
18
  it 'should throw an error if passed something that is not a repository' do
18
- expect{subject.add_repository :name, :not_a_repo}.to raise_error
19
+ expect{subject.add_repository :name, :not_a_repo}
20
+ .to raise_error ArgumentError
19
21
  end
20
22
  end
21
23
 
@@ -1,16 +1,20 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe ActiveTriples::Resource do
4
- it_behaves_like 'an ActiveModel'
5
+ it_behaves_like 'an ActiveModel' do
6
+ let(:am_lint_class) { described_class }
7
+ end
8
+
5
9
  before do
6
10
  class DummyLicense < ActiveTriples::Resource
7
- property :title, :predicate => RDF::DC.title
11
+ property :title, :predicate => RDF::Vocab::DC.title
8
12
  end
9
13
 
10
14
  class DummyResource < ActiveTriples::Resource
11
15
  configure :type => RDF::URI('http://example.org/SomeClass')
12
- property :license, :predicate => RDF::DC.license, :class_name => DummyLicense
13
- property :title, :predicate => RDF::DC.title
16
+ property :license, :predicate => RDF::Vocab::DC.license, :class_name => DummyLicense
17
+ property :title, :predicate => RDF::Vocab::DC.title
14
18
  end
15
19
  end
16
20
  after do
@@ -22,7 +26,29 @@ describe ActiveTriples::Resource do
22
26
 
23
27
  describe '#property' do
24
28
  it 'raises error when set directly on Resource' do
25
- expect { ActiveTriples::Resource.property :blah, :predicate => RDF::DC.title }.to raise_error
29
+ expect { ActiveTriples::Resource.property :p, predicate: RDF::Vocab::DC.title }
30
+ .to raise_error 'Properties not definable directly on ' \
31
+ 'ActiveTriples::Resource, use a subclass'
32
+ end
33
+ end
34
+
35
+ describe 'setting properties' do
36
+ before do
37
+ class DummyWithClass < ActiveTriples::Resource
38
+ configure :type => RDF::URI('http://example.org/DummyClass')
39
+ end
40
+ end
41
+
42
+ after { Object.send(:remove_const, "DummyWithClass") }
43
+
44
+ it 'should replace property value when Resource class has a rdf type' do
45
+ dl1 = DummyWithClass.new('http://example.org/dl1')
46
+ dl2 = DummyWithClass.new('http://example.org/dl2')
47
+
48
+ subject.title = dl1
49
+ expect( subject.title ).to eq [dl1]
50
+ subject.title = dl2
51
+ expect( subject.title ).to eq [dl2]
26
52
  end
27
53
  end
28
54
 
@@ -42,22 +68,22 @@ describe ActiveTriples::Resource do
42
68
 
43
69
  describe 'when changing subject' do
44
70
  before do
45
- subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
46
- subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
47
- subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
71
+ subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland'))
72
+ subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject)
73
+ subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land')
48
74
  subject.set_subject! RDF::URI('http://example.org/moomin')
49
75
  end
50
76
 
51
77
  it 'should update graph subjects' do
52
- expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
78
+ expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
53
79
  end
54
80
 
55
81
  it 'should update graph objects' do
56
- expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
82
+ expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
57
83
  end
58
84
 
59
85
  it 'should leave other uris alone' do
60
- expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
86
+ expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land'))).to be true
61
87
  end
62
88
  end
63
89
 
@@ -67,7 +93,8 @@ describe ActiveTriples::Resource do
67
93
  end
68
94
 
69
95
  it 'should not be settable' do
70
- expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
96
+ expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }
97
+ .to raise_error 'Refusing update URI when one is already assigned!'
71
98
  end
72
99
  end
73
100
 
@@ -292,14 +319,14 @@ describe ActiveTriples::Resource do
292
319
 
293
320
  it "should warn when the repo doesn't exist" do
294
321
  allow(DummyLicense).to receive(:repository).and_return('repo2')
295
- expect { subject }.to raise_error ActiveTriples::RepositoryNotFoundError, 'The class DummyLicense expects a repository called repo2, but none was declared'
322
+ expect { subject }.to raise_error ActiveTriples::RepositoryNotFoundError
296
323
  end
297
324
  end
298
325
 
299
326
  describe '#destroy!' do
300
327
  before do
301
328
  subject.title = 'Creative Commons'
302
- subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
329
+ subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
303
330
  end
304
331
 
305
332
  subject { DummyLicense.new('http://example.org/cc')}
@@ -315,33 +342,30 @@ describe ActiveTriples::Resource do
315
342
  end
316
343
 
317
344
  context 'with a parent' do
318
- before do
319
- parent.license = subject
320
- end
345
+ before { parent.license = subject }
321
346
 
322
347
  let(:parent) do
323
348
  DummyResource.new('http://example.org/moomi')
324
349
  end
325
350
 
326
- it 'should empty the graph and remove it from the parent' do
327
- subject.destroy
328
- expect(parent.license).to be_empty
351
+ it 'empties the graph and removes it from the parent' do
352
+ expect { parent.license.first.destroy! }
353
+ .to change { parent.license.empty? }.to true
329
354
  end
330
355
 
331
- it 'should remove its whole graph from the parent' do
332
- subject.destroy
333
- subject.each_statement do |s|
334
- expect(parent.statements).not_to include s
335
- end
356
+ it 'removes its whole graph from the parent' do
357
+ statements = subject.statements.to_a
358
+ parent.license.first.destroy
359
+ statements.each { |s| expect(parent.statements).not_to include s }
336
360
  end
337
361
  end
338
362
  end
339
363
 
340
364
  describe 'class_name' do
341
365
  it 'should raise an error when not a class or string' do
342
- DummyResource.property :relation, :predicate => RDF::DC.relation, :class_name => RDF::URI('http://example.org')
366
+ DummyResource.property :relation, :predicate => RDF::Vocab::DC.relation, :class_name => RDF::URI('http://example.org')
343
367
  d = DummyResource.new
344
- d.relation = RDF::DC.type
368
+ d.relation = RDF::Vocab::DC.type
345
369
  expect { d.relation.first }.to raise_error "class_name for relation is a RDF::URI; must be a class"
346
370
  end
347
371
 
@@ -391,29 +415,29 @@ describe ActiveTriples::Resource do
391
415
 
392
416
  context 'with unmodeled data' do
393
417
  before do
394
- subject << RDF::Statement(subject.rdf_subject, RDF::DC.contributor, 'Tove Jansson')
395
- subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi'))
418
+ subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.contributor, 'Tove Jansson')
419
+ subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi'))
396
420
  node = RDF::Node.new
397
- subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node)
398
- subject << RDF::Statement(node, RDF::DC.title, 'bnode')
421
+ subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node)
422
+ subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode')
399
423
  end
400
424
 
401
425
  it 'should include data with URIs as attribute names' do
402
- expect(subject.attributes[RDF::DC.contributor.to_s]).to eq ['Tove Jansson']
426
+ expect(subject.attributes[RDF::Vocab::DC.contributor.to_s]).to eq ['Tove Jansson']
403
427
  end
404
428
 
405
429
  it 'should return generic Resources' do
406
- expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource
430
+ expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource
407
431
  end
408
432
 
409
433
  it 'should build deep data for Resources' do
410
- expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
411
- first.get_values(RDF::DC.title)).to eq ['bnode']
434
+ expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
435
+ first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
412
436
  end
413
437
 
414
438
  it 'should include deep data in serializable_hash' do
415
- expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
416
- first.get_values(RDF::DC.title)).to eq ['bnode']
439
+ expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
440
+ first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
417
441
  end
418
442
  end
419
443
 
@@ -434,69 +458,6 @@ describe ActiveTriples::Resource do
434
458
  end
435
459
  end
436
460
 
437
- describe 'array setters' do
438
- before do
439
- DummyResource.property :aggregates, :predicate => RDF::DC.relation
440
- end
441
-
442
- it "should be empty array if we haven't set it" do
443
- expect(subject.aggregates).to match_array([])
444
- end
445
-
446
- context "when set to a URI" do
447
- let(:aggregates_uri) { RDF::URI("http://example.org/b1") }
448
- before do
449
- subject.aggregates = aggregates_uri
450
- end
451
- it "produce an ActiveTriple::Resource" do
452
- expect(subject.aggregates.first).to be_a ActiveTriples::Resource
453
- end
454
- it "should have an ID accessor" do
455
- expect(subject.aggregates_ids).to eq [aggregates_uri]
456
- end
457
- end
458
-
459
- it "should be settable" do
460
- subject.aggregates = RDF::URI("http://example.org/b1")
461
- expect(subject.aggregates.first.rdf_subject).to eq RDF::URI("http://example.org/b1")
462
- ['id']
463
- end
464
-
465
- context 'with values' do
466
- let(:bib1) { RDF::URI("http://example.org/b1") }
467
- let(:bib2) { RDF::URI("http://example.org/b2") }
468
- let(:bib3) { RDF::URI("http://example.org/b3") }
469
-
470
- before do
471
- subject.aggregates = bib1
472
- subject.aggregates << bib2
473
- subject.aggregates << bib3
474
- end
475
-
476
- it 'raises error when trying to set nil value' do
477
- expect { subject.aggregates[1] = nil }.to raise_error /value must be an RDF URI, Node, Literal, or a valid datatype/
478
- end
479
-
480
- it "should be changeable for multiple values" do
481
- new_bib1 = RDF::URI("http://example.org/b1_NEW")
482
- new_bib3 = RDF::URI("http://example.org/b3_NEW")
483
-
484
- aggregates = subject.aggregates.dup
485
- aggregates[0] = new_bib1
486
- aggregates[2] = new_bib3
487
- subject.aggregates = aggregates
488
-
489
- expect(subject.aggregates[0].rdf_subject).to eq new_bib1
490
- expect(subject.aggregates[1].rdf_subject).to eq bib2
491
- expect(subject.aggregates[2].rdf_subject).to eq new_bib3
492
- end
493
-
494
- it "raises an error for out of bounds index" do
495
- expect { subject.aggregates[4] = 'blah' }.to raise_error IndexError
496
- end
497
- end
498
- end
499
-
500
461
  describe 'child nodes' do
501
462
  it 'should return an object of the correct class when the value is a URI' do
502
463
  subject.license = DummyLicense.new('http://example.org/license')
@@ -516,22 +477,22 @@ describe ActiveTriples::Resource do
516
477
 
517
478
  describe '#set_value' do
518
479
  it 'should set a value in the graph' do
519
- subject.set_value(RDF::DC.title, 'Comet in Moominland')
520
- subject.query(:subject => subject.rdf_subject, :predicate => RDF::DC.title).each_statement do |s|
480
+ subject.set_value(RDF::Vocab::DC.title, 'Comet in Moominland')
481
+ subject.query(:subject => subject.rdf_subject, :predicate => RDF::Vocab::DC.title).each_statement do |s|
521
482
  expect(s.object.to_s).to eq 'Comet in Moominland'
522
483
  end
523
484
  end
524
485
 
525
486
  context "when given a URI" do
526
487
  before do
527
- subject.set_value(RDF::DC.title, RDF::URI("http://opaquenamespace.org/jokes/1"))
488
+ subject.set_value(RDF::Vocab::DC.title, RDF::URI("http://opaquenamespace.org/jokes/1"))
528
489
  end
529
490
  it "should return a resource" do
530
491
  expect(subject.title.first).to be_kind_of(ActiveTriples::RDFSource)
531
492
  end
532
493
  context "and it's configured to not cast" do
533
494
  before do
534
- subject.class.property :title, predicate: RDF::DC.title, cast: false
495
+ subject.class.property :title, predicate: RDF::Vocab::DC.title, cast: false
535
496
  end
536
497
  it "should return a URI" do
537
498
  expect(subject.title.first).to be_kind_of(RDF::URI)
@@ -559,20 +520,21 @@ describe ActiveTriples::Resource do
559
520
  expect(subject.title).to eq ['Comet in Moominland']
560
521
  end
561
522
 
562
- it "raise an error if the value is not a URI, Node, Literal, RdfResource, or string" do
563
- expect{subject.set_value(RDF::DC.title, Object.new)}.to raise_error
523
+ it "raise an error if the value is not a Term" do
524
+ expect{ subject.set_value(RDF::Vocab::DC.title, Object.new) }
525
+ .to raise_error ActiveTriples::Relation::ValueError
564
526
  end
565
527
 
566
528
  it "should be able to accept a subject" do
567
- expect{subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::DC.title, 'Comet in Moominland')}.not_to raise_error
568
- expect(subject.query(:subject => RDF::URI("http://opaquenamespace.org/jokes"), :predicate => RDF::DC.title).statements.to_a.length).to eq 1
529
+ expect{subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, 'Comet in Moominland')}.not_to raise_error
530
+ expect(subject.query(:subject => RDF::URI("http://opaquenamespace.org/jokes"), :predicate => RDF::Vocab::DC.title).statements.to_a.length).to eq 1
569
531
  end
570
532
  end
571
533
 
572
534
  describe '#[]=' do
573
535
  it 'should set a value in the graph' do
574
- subject[RDF::DC.title] = 'Comet in Moominland'
575
- subject.query(:subject => subject.rdf_subject, :predicate => RDF::DC.title).each_statement do |s|
536
+ subject[RDF::Vocab::DC.title] = 'Comet in Moominland'
537
+ subject.query(:subject => subject.rdf_subject, :predicate => RDF::Vocab::DC.title).each_statement do |s|
576
538
  expect(s.object.to_s).to eq 'Comet in Moominland'
577
539
  end
578
540
  end
@@ -583,7 +545,8 @@ describe ActiveTriples::Resource do
583
545
  end
584
546
 
585
547
  it "raise an error if the value is not a URI, Node, Literal, RdfResource, or string" do
586
- expect { subject[RDF::DC.title] = Object.new }.to raise_error
548
+ expect { subject[RDF::Vocab::DC.title] = Object.new }
549
+ .to raise_error ActiveTriples::Relation::ValueError
587
550
  end
588
551
  end
589
552
 
@@ -593,7 +556,7 @@ describe ActiveTriples::Resource do
593
556
  end
594
557
 
595
558
  it 'should return values for a predicate uri' do
596
- expect(subject.get_values(RDF::DC.title)).to eq ['Comet in Moominland', 'Finn Family Moomintroll']
559
+ expect(subject.get_values(RDF::Vocab::DC.title)).to eq ['Comet in Moominland', 'Finn Family Moomintroll']
597
560
  end
598
561
 
599
562
  it 'should return values for a registered predicate symbol' do
@@ -602,7 +565,7 @@ describe ActiveTriples::Resource do
602
565
 
603
566
  it "should return values for other subjects if asked" do
604
567
  expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq []
605
- subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::DC.title, 'Comet in Moominland')
568
+ subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, 'Comet in Moominland')
606
569
  expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq ["Comet in Moominland"]
607
570
  end
608
571
 
@@ -610,21 +573,20 @@ describe ActiveTriples::Resource do
610
573
  let(:literal1) { RDF::Literal.new("test", :language => :en) }
611
574
  let(:literal2) { RDF::Literal.new("test", :language => :fr) }
612
575
  before do
613
- subject.set_value(RDF::DC.title, [literal1, literal2])
576
+ subject.set_value(RDF::Vocab::DC.title, [literal1, literal2])
614
577
  end
615
578
  context "and literals are not requested" do
616
579
  it "should return a string" do
617
580
  # Should this de-duplicate?
618
- expect(subject.get_values(RDF::DC.title)).to eq ["test", "test"]
581
+ expect(subject.get_values(RDF::Vocab::DC.title)).to eq ["test", "test"]
619
582
  end
620
583
  end
621
584
  context "and literals are requested" do
622
585
  it "should return literals" do
623
- expect(subject.get_values(RDF::DC.title, :literal => true)).to eq [literal1, literal2]
586
+ expect(subject.get_values(RDF::Vocab::DC.title, :literal => true)).to eq [literal1, literal2]
624
587
  end
625
588
  end
626
589
  end
627
-
628
590
  end
629
591
 
630
592
  describe '#[]' do
@@ -633,7 +595,7 @@ describe ActiveTriples::Resource do
633
595
  end
634
596
 
635
597
  it 'should return values for a predicate uri' do
636
- expect(subject[RDF::DC.title]).to eq ['Comet in Moominland', 'Finn Family Moomintroll']
598
+ expect(subject[RDF::Vocab::DC.title]).to eq ['Comet in Moominland', 'Finn Family Moomintroll']
637
599
  end
638
600
 
639
601
  it 'should return values for a registered predicate symbol' do
@@ -642,7 +604,7 @@ describe ActiveTriples::Resource do
642
604
 
643
605
  it "should return values for other subjects if asked" do
644
606
  expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq []
645
- subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::DC.title, 'Comet in Moominland')
607
+ subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, 'Comet in Moominland')
646
608
  expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq ["Comet in Moominland"]
647
609
  end
648
610
  end
@@ -664,34 +626,15 @@ describe ActiveTriples::Resource do
664
626
  end
665
627
  end
666
628
 
667
- describe '#rdf_label' do
668
- it 'should return an array of label values' do
669
- expect(subject.rdf_label).to be_kind_of Array
670
- end
671
-
672
- it 'should return the default label values' do
673
- subject.title = 'Comet in Moominland'
674
- expect(subject.rdf_label).to eq ['Comet in Moominland']
675
- end
676
-
677
- it 'should prioritize configured label values' do
678
- custom_label = RDF::URI('http://example.org/custom_label')
679
- subject.class.configure :rdf_label => custom_label
680
- subject << RDF::Statement(subject.rdf_subject, custom_label, RDF::Literal('New Label'))
681
- subject.title = 'Comet in Moominland'
682
- expect(subject.rdf_label).to eq ['New Label']
683
- end
684
- end
685
-
686
629
  describe 'editing the graph' do
687
630
  it 'should write properties when statements are added' do
688
- subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland')
631
+ subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, 'Comet in Moominland')
689
632
  expect(subject.title).to include 'Comet in Moominland'
690
633
  end
691
634
 
692
635
  it 'should delete properties when statements are removed' do
693
- subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland')
694
- subject.delete RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland')
636
+ subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, 'Comet in Moominland')
637
+ subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, 'Comet in Moominland')
695
638
  expect(subject.title).to eq []
696
639
  end
697
640
  end
@@ -701,19 +644,19 @@ describe ActiveTriples::Resource do
701
644
  class DummyPerson
702
645
  include ActiveTriples::RDFSource
703
646
  configure :type => RDF::URI('http://example.org/Person')
704
- property :foaf_name, :predicate => RDF::FOAF.name
705
- property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
706
- property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
647
+ property :foaf_name, :predicate => RDF::Vocab::FOAF.name
648
+ property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
649
+ property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
707
650
  end
708
651
 
709
652
  class DummyDocument
710
653
  include ActiveTriples::RDFSource
711
654
  configure :type => RDF::URI('http://example.org/Document')
712
- property :title, :predicate => RDF::DC.title
713
- property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
655
+ property :title, :predicate => RDF::Vocab::DC.title
656
+ property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
714
657
  end
715
658
 
716
- DummyResource.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
659
+ DummyResource.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
717
660
  end
718
661
 
719
662
  subject { DummyResource.new }