This repository has been archived by the owner on Sep 12, 2018. It is now read-only.
forked from ruby-rdf/spira
/
enumerable.spec
70 lines (53 loc) · 2.47 KB
/
enumerable.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require File.dirname(File.expand_path(__FILE__)) + '/spec_helper'
# Tests in terms of RDF::Enumerable, and interaction with other enumerables
describe Spira::Resource do
context "as an RDF::Enumerable" do
before :all do
require 'rdf/ntriples'
Spira.add_repository(:default, ::RDF::Repository)
class ::EnumerableSpec
include Spira::Resource
base_uri "http://example.org/example/people"
property :name, :predicate => RDFS.label
property :age, :predicate => FOAF.age, :type => Integer
end
end
before :each do
@uri = RDF::URI('http://example.org/example/people/bob')
@person = EnumerableSpec.for @uri
@enumerable_repository = RDF::Repository.new
@enumerable_repository << RDF::Statement.new(@uri, RDF::FOAF.age, 15)
@enumerable_repository << RDF::Statement.new(@uri, RDF::RDFS.label, "Bob Smith")
@statements = @enumerable_repository
@person.name = "Bob Smith"
@person.age = 15
@enumerable = @person
end
context "when running the rdf-spec RDF::Enumerable shared groups" do
it_should_behave_like RDF_Enumerable
end
context "when comparing with other RDF::Enumerables" do
it "should be equal if they are completely the same" do
@enumerable.should == @enumerable_repository
end
# This one is a tough call. Are two resources really equal if one is a
# subset of the other? No. But Spira is supposed to let you access
# existing data, and that means you might have data which has properties
# a model class doesn't know about.
#
# Spira will default, then, to calling itself equal to an enumerable
# which has the same uri and all the same properties, and then some.
it "should be equal if the resource is a subgraph of the repository" do
pending "Awaiting subgraph implementation in rdf_isomorphic"
end
it "should allow other enumerables to be isomorphic to a resource" do
#pending "what to do here? monkey-patching rdf::enumerable wont work for implementations which override that anyway."
@enumerable_repository.should be_isomorphic_with @enumerable
end
it "should allow other enumerables to be == to a resource" do
pending "what to do here? monkey-patching rdf::enumerable wont work for implementations which override that anyway."
@enumerable_repository.should == @enumerable
end
end
end
end