active-fedora 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/.hg/00changelog.i +0 -0
  4. data/.hg/branch +1 -0
  5. data/.hg/branch.cache +2 -0
  6. data/.hg/dirstate +0 -0
  7. data/.hg/hgrc +2 -0
  8. data/.hg/requires +2 -0
  9. data/.hg/store/00changelog.i +0 -0
  10. data/.hg/store/00manifest.i +0 -0
  11. data/.hg/store/data/.hgignore.i +0 -0
  12. data/.hg/store/data/.hgtags.i +0 -0
  13. data/.hg/store/data/_c_o_p_y_i_n_g.txt.i +0 -0
  14. data/.hg/store/data/_c_o_y_i_n_g._l_e_s_s_e_r.txt.i +0 -0
  15. data/.hg/store/data/_history.txt.i +0 -0
  16. data/.hg/store/data/_license.txt.i +0 -0
  17. data/.hg/store/data/_manifest.txt.i +0 -0
  18. data/.hg/store/data/_post_install.txt.i +0 -0
  19. data/.hg/store/data/_r_e_a_d_m_e.rdoc.i +0 -0
  20. data/.hg/store/data/_r_e_a_d_m_e.txt.i +0 -0
  21. data/.hg/store/data/_rakefile.i +0 -0
  22. data/.hg/store/data/_v_e_r_s_i_o_n.i +0 -0
  23. data/.hg/store/data/active-fedora.gemspec.i +0 -0
  24. data/.hg/store/data/active__fedora/_history.txt.i +0 -0
  25. data/.hg/store/data/active__fedora/_manifest.txt.i +0 -0
  26. data/.hg/store/data/active__fedora/_post_install.txt.i +0 -0
  27. data/.hg/store/data/active__fedora/_r_e_a_d_m_e.rdoc.i +0 -0
  28. data/.hg/store/data/active__fedora/_rakefile.i +0 -0
  29. data/.hg/store/data/active__fedora/lib/active__fedora.rb.i +0 -0
  30. data/.hg/store/data/active__fedora/script/console.i +0 -0
  31. data/.hg/store/data/active__fedora/script/destroy.i +0 -0
  32. data/.hg/store/data/active__fedora/script/generate.i +0 -0
  33. data/.hg/store/data/active__fedora/spec/active__fedora__spec.rb.i +0 -0
  34. data/.hg/store/data/active__fedora/spec/spec__helper.rb.i +0 -0
  35. data/.hg/store/data/config/fedora.yml.i +0 -0
  36. data/.hg/store/data/config/solr__mappings.yml.i +0 -0
  37. data/.hg/store/data/config/solr__mappings__af__0.1.yml.i +0 -0
  38. data/.hg/store/data/config/solr__mappings__bl__2.4.yml.i +0 -0
  39. data/.hg/store/data/lib/active-fedora.rb.i +0 -0
  40. data/.hg/store/data/lib/active__fedora.rb.i +0 -0
  41. data/.hg/store/data/lib/active__fedora/base.rb.i +0 -0
  42. data/.hg/store/data/lib/active__fedora/content__model.rb.i +0 -0
  43. data/.hg/store/data/lib/active__fedora/datastream.rb.i +0 -0
  44. data/.hg/store/data/lib/active__fedora/fedora__object.rb.i +0 -0
  45. data/.hg/store/data/lib/active__fedora/metadata__datastream.rb.i +0 -0
  46. data/.hg/store/data/lib/active__fedora/model.rb.i +0 -0
  47. data/.hg/store/data/lib/active__fedora/property.rb.i +0 -0
  48. data/.hg/store/data/lib/active__fedora/qualified__dublin__core__datastream.rb.i +0 -0
  49. data/.hg/store/data/lib/active__fedora/relationship.rb.i +0 -0
  50. data/.hg/store/data/lib/active__fedora/rels__ext__datastream.rb.i +0 -0
  51. data/.hg/store/data/lib/active__fedora/semantic__node.rb.i +0 -0
  52. data/.hg/store/data/lib/active__fedora/solr__mapper.rb.i +0 -0
  53. data/.hg/store/data/lib/active__fedora/solr__service.rb.i +0 -0
  54. data/.hg/store/data/lib/fedora/base.rb.i +0 -0
  55. data/.hg/store/data/lib/fedora/connection.rb.i +0 -0
  56. data/.hg/store/data/lib/fedora/datastream.rb.i +0 -0
  57. data/.hg/store/data/lib/fedora/fedora__object.rb.i +0 -0
  58. data/.hg/store/data/lib/fedora/formats.rb.i +0 -0
  59. data/.hg/store/data/lib/fedora/generic__search.rb.i +0 -0
  60. data/.hg/store/data/lib/fedora/repository.rb.i +0 -0
  61. data/.hg/store/data/lib/ruby-fedora.rb.i +0 -0
  62. data/.hg/store/data/lib/util/class__level__inheritable__attributes.rb.i +0 -0
  63. data/.hg/store/data/script/console.i +0 -0
  64. data/.hg/store/data/script/destroy.i +0 -0
  65. data/.hg/store/data/script/generate.i +0 -0
  66. data/.hg/store/data/solr/config/schema-1.5.xml.i +0 -0
  67. data/.hg/store/data/solr/config/schema.xml.i +0 -0
  68. data/.hg/store/data/solr/config/solrconfig-1.5.xml.i +0 -0
  69. data/.hg/store/data/spec/fixtures/changeme155.xml.i +0 -0
  70. data/.hg/store/data/spec/fixtures/dino.jpg.i +0 -0
  71. data/.hg/store/data/spec/fixtures/minivan.jpg.d +0 -0
  72. data/.hg/store/data/spec/fixtures/minivan.jpg.i +0 -0
  73. data/.hg/store/data/spec/fixtures/test__12.foxml.xml.i +0 -0
  74. data/.hg/store/data/spec/integration/active__fedora/base__spec.rb.i +0 -0
  75. data/.hg/store/data/spec/integration/active__fedora/datastream__spec.rb.i +0 -0
  76. data/.hg/store/data/spec/integration/active__fedora/fedora__object__spec.rb.i +0 -0
  77. data/.hg/store/data/spec/integration/active__fedora/full__featured__model__spec.rb.i +0 -0
  78. data/.hg/store/data/spec/integration/active__fedora/model__spec.rb.i +0 -0
  79. data/.hg/store/data/spec/integration/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  80. data/.hg/store/data/spec/integration/active__fedora/semantic__node__spec.rb.i +0 -0
  81. data/.hg/store/data/spec/integration/base__file__management__spec.rb.i +0 -0
  82. data/.hg/store/data/spec/integration/base__spec.rb.i +0 -0
  83. data/.hg/store/data/spec/integration/bug__spec.rb.i +0 -0
  84. data/.hg/store/data/spec/integration/datastream__spec.rb.i +0 -0
  85. data/.hg/store/data/spec/integration/datastreams__crud__spec.rb.i +0 -0
  86. data/.hg/store/data/spec/integration/fedora__object__spec.rb.i +0 -0
  87. data/.hg/store/data/spec/integration/full__featured__model__spec.rb.i +0 -0
  88. data/.hg/store/data/spec/integration/model__spec.rb.i +0 -0
  89. data/.hg/store/data/spec/integration/rels__ext__datastream__spec.rb.i +0 -0
  90. data/.hg/store/data/spec/integration/repository__spec.rb.i +0 -0
  91. data/.hg/store/data/spec/integration/rf__fedora__object__spec.rb.i +0 -0
  92. data/.hg/store/data/spec/integration/semantic__node__spec.rb.i +0 -0
  93. data/.hg/store/data/spec/integration/solr__service__spec.rb.i +0 -0
  94. data/.hg/store/data/spec/samples/models/audio__record.rb.i +0 -0
  95. data/.hg/store/data/spec/samples/models/image.rb.i +0 -0
  96. data/.hg/store/data/spec/samples/models/oral__history.rb.i +0 -0
  97. data/.hg/store/data/spec/samples/models/seminar.rb.i +0 -0
  98. data/.hg/store/data/spec/samples/models/seminar__audio__file.rb.i +0 -0
  99. data/.hg/store/data/spec/samples/oh__qdc.xml.i +0 -0
  100. data/.hg/store/data/spec/samples/oral__history.rb.i +0 -0
  101. data/.hg/store/data/spec/samples/oral__history__sample.xml.i +0 -0
  102. data/.hg/store/data/spec/samples/oral__history__sample__model.rb.i +0 -0
  103. data/.hg/store/data/spec/samples/oral__history__xml.xml.i +0 -0
  104. data/.hg/store/data/spec/spec.opts.i +0 -0
  105. data/.hg/store/data/spec/spec__helper.rb.i +0 -0
  106. data/.hg/store/data/spec/unit/active__fedora/base__cma__spec.rb.i +0 -0
  107. data/.hg/store/data/spec/unit/active__fedora/base__extra__spec.rb.i +0 -0
  108. data/.hg/store/data/spec/unit/active__fedora/base__spec.rb.i +0 -0
  109. data/.hg/store/data/spec/unit/active__fedora/content__model__spec.rb.i +0 -0
  110. data/.hg/store/data/spec/unit/active__fedora/datastream__spec.rb.i +0 -0
  111. data/.hg/store/data/spec/unit/active__fedora/inheritance__spec.rb.i +0 -0
  112. data/.hg/store/data/spec/unit/active__fedora/metadata__datastream__spec.rb.i +0 -0
  113. data/.hg/store/data/spec/unit/active__fedora/model__spec.rb.i +0 -0
  114. data/.hg/store/data/spec/unit/active__fedora/property__spec.rb.i +0 -0
  115. data/.hg/store/data/spec/unit/active__fedora/qualified__dublin__core__datastream__spec.rb.i +0 -0
  116. data/.hg/store/data/spec/unit/active__fedora/relationship__spec.rb.i +0 -0
  117. data/.hg/store/data/spec/unit/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  118. data/.hg/store/data/spec/unit/active__fedora/semantic__node__spec.rb.i +0 -0
  119. data/.hg/store/data/spec/unit/active__fedora/solr__service__spec.rb.i +0 -0
  120. data/.hg/store/data/spec/unit/active__fedora__spec.rb.i +0 -0
  121. data/.hg/store/data/spec/unit/base__cma__spec.rb.i +0 -0
  122. data/.hg/store/data/spec/unit/base__datastream__management__spec.rb.i +0 -0
  123. data/.hg/store/data/spec/unit/base__extra__spec.rb.i +0 -0
  124. data/.hg/store/data/spec/unit/base__file__management__spec.rb.i +0 -0
  125. data/.hg/store/data/spec/unit/base__loader__spec.rb.i +0 -0
  126. data/.hg/store/data/spec/unit/base__spec.rb.i +0 -0
  127. data/.hg/store/data/spec/unit/connection__spec.rb.i +0 -0
  128. data/.hg/store/data/spec/unit/content__model__spec.rb.i +0 -0
  129. data/.hg/store/data/spec/unit/datastream__concurrency__spec.rb.i +0 -0
  130. data/.hg/store/data/spec/unit/datastream__spec.rb.i +0 -0
  131. data/.hg/store/data/spec/unit/fedora__object__spec.rb.i +0 -0
  132. data/.hg/store/data/spec/unit/inheritance__spec.rb.i +0 -0
  133. data/.hg/store/data/spec/unit/metadata__datastream__spec.rb.i +0 -0
  134. data/.hg/store/data/spec/unit/model__spec.rb.i +0 -0
  135. data/.hg/store/data/spec/unit/property__spec.rb.i +0 -0
  136. data/.hg/store/data/spec/unit/qualified__dublin__core__datastream__spec.rb.i +0 -0
  137. data/.hg/store/data/spec/unit/relationship__spec.rb.i +0 -0
  138. data/.hg/store/data/spec/unit/rels__ext__datastream__spec.rb.i +0 -0
  139. data/.hg/store/data/spec/unit/repository__spec.rb.i +0 -0
  140. data/.hg/store/data/spec/unit/rf__datastream__spec.rb.i +0 -0
  141. data/.hg/store/data/spec/unit/semantic__node__spec.rb.i +0 -0
  142. data/.hg/store/data/spec/unit/solr__config__options__spec.rb.i +0 -0
  143. data/.hg/store/data/spec/unit/solr__mapper__spec.rb.i +0 -0
  144. data/.hg/store/data/spec/unit/solr__service__spec.rb.i +0 -0
  145. data/.hg/store/data/tasks/rspec.rake.i +0 -0
  146. data/.hg/store/undo +0 -0
  147. data/.hg/undo.branch +1 -0
  148. data/.hg/undo.dirstate +0 -0
  149. data/.hgignore +7 -0
  150. data/.hgtags +14 -0
  151. data/COPYING.txt +674 -0
  152. data/COYING.LESSER.txt +165 -0
  153. data/History.txt +34 -0
  154. data/LICENSE +20 -0
  155. data/License.txt +58 -0
  156. data/Manifest.txt +1 -1
  157. data/README.rdoc +13 -54
  158. data/README.txt +59 -0
  159. data/Rakefile +35 -0
  160. data/VERSION +1 -0
  161. data/active-fedora.gemspec +359 -0
  162. data/config/fedora.yml +16 -0
  163. data/config/solr_mappings.yml +14 -0
  164. data/config/solr_mappings_af_0.1.yml +16 -0
  165. data/config/solr_mappings_bl_2.4.yml +14 -0
  166. data/lib/active_fedora.rb +66 -6
  167. data/lib/active_fedora/base.rb +59 -23
  168. data/lib/active_fedora/datastream.rb +1 -1
  169. data/lib/active_fedora/metadata_datastream.rb +14 -7
  170. data/lib/active_fedora/model.rb +4 -4
  171. data/lib/active_fedora/rels_ext_datastream.rb +1 -1
  172. data/lib/active_fedora/semantic_node.rb +4 -3
  173. data/lib/active_fedora/solr_mapper.rb +17 -0
  174. data/lib/active_fedora/solr_service.rb +44 -2
  175. data/lib/fedora/base.rb +38 -0
  176. data/lib/fedora/connection.rb +210 -0
  177. data/lib/fedora/datastream.rb +56 -0
  178. data/lib/fedora/fedora_object.rb +161 -0
  179. data/lib/fedora/formats.rb +30 -0
  180. data/lib/fedora/generic_search.rb +71 -0
  181. data/lib/fedora/repository.rb +287 -0
  182. data/lib/ruby-fedora.rb +20 -0
  183. data/lib/util/class_level_inheritable_attributes.rb +23 -0
  184. data/script/console +15 -0
  185. data/script/destroy +14 -0
  186. data/script/generate +14 -0
  187. data/solr/config/schema-1.5.xml +468 -0
  188. data/solr/config/schema.xml +174 -212
  189. data/solr/config/solrconfig-1.5.xml +1069 -0
  190. data/spec/active_fedora_spec.rb +7 -0
  191. data/spec/fixtures/changeme155.xml +255 -0
  192. data/spec/fixtures/dino.jpg +0 -0
  193. data/spec/fixtures/minivan.jpg +0 -0
  194. data/spec/fixtures/test_12.foxml.xml +121 -0
  195. data/spec/integration/base_file_management_spec.rb +20 -0
  196. data/spec/integration/base_spec.rb +196 -0
  197. data/spec/integration/bug_spec.rb +57 -0
  198. data/spec/integration/datastream_spec.rb +60 -0
  199. data/spec/integration/datastreams_crud_spec.rb +208 -0
  200. data/spec/integration/fedora_object_spec.rb +77 -0
  201. data/spec/integration/full_featured_model_spec.rb +207 -0
  202. data/spec/integration/model_spec.rb +54 -0
  203. data/spec/integration/rels_ext_datastream_spec.rb +67 -0
  204. data/spec/integration/repository_spec.rb +297 -0
  205. data/spec/integration/rf_fedora_object_spec.rb +95 -0
  206. data/spec/integration/semantic_node_spec.rb +95 -0
  207. data/spec/integration/solr_service_spec.rb +33 -0
  208. data/spec/samples/models/audio_record.rb +29 -0
  209. data/spec/samples/models/image.rb +5 -0
  210. data/spec/samples/models/oral_history.rb +50 -0
  211. data/spec/samples/models/seminar.rb +29 -0
  212. data/spec/samples/models/seminar_audio_file.rb +34 -0
  213. data/spec/samples/oh_qdc.xml +32 -0
  214. data/spec/samples/oral_history_sample.xml +38 -0
  215. data/spec/samples/oral_history_sample_model.rb +39 -0
  216. data/spec/samples/oral_history_xml.xml +35 -0
  217. data/spec/spec.opts +5 -0
  218. data/spec/spec_helper.rb +41 -0
  219. data/spec/unit/active_fedora_spec.rb +15 -0
  220. data/spec/unit/base_cma_spec.rb +25 -0
  221. data/spec/unit/base_datastream_management_spec.rb +119 -0
  222. data/spec/unit/base_extra_spec.rb +108 -0
  223. data/spec/unit/base_file_management_spec.rb +90 -0
  224. data/spec/unit/base_loader_spec.rb +43 -0
  225. data/spec/unit/base_spec.rb +584 -0
  226. data/spec/unit/connection_spec.rb +25 -0
  227. data/spec/unit/content_model_spec.rb +51 -0
  228. data/spec/unit/datastream_concurrency_spec.rb +59 -0
  229. data/spec/unit/datastream_spec.rb +85 -0
  230. data/spec/unit/fedora_object_spec.rb +66 -0
  231. data/spec/unit/inheritance_spec.rb +46 -0
  232. data/spec/unit/metadata_datastream_spec.rb +290 -0
  233. data/spec/unit/model_spec.rb +186 -0
  234. data/spec/unit/property_spec.rb +50 -0
  235. data/spec/unit/qualified_dublin_core_datastream_spec.rb +177 -0
  236. data/spec/unit/relationship_spec.rb +77 -0
  237. data/spec/unit/rels_ext_datastream_spec.rb +99 -0
  238. data/spec/unit/repository_spec.rb +136 -0
  239. data/spec/unit/rf_datastream_spec.rb +49 -0
  240. data/spec/unit/semantic_node_spec.rb +354 -0
  241. data/spec/unit/solr_config_options_spec.rb +98 -0
  242. data/spec/unit/solr_mapper_spec.rb +31 -0
  243. data/spec/unit/solr_service_spec.rb +83 -0
  244. data/tasks/hoe.rake +0 -0
  245. data/tasks/rspec.rake +29 -0
  246. metadata +373 -55
@@ -0,0 +1,99 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'active_fedora'
4
+ require "rexml/document"
5
+ require 'ftools'
6
+
7
+ describe ActiveFedora::RelsExtDatastream do
8
+
9
+ before(:all) do
10
+ @pid = "test:sample_pid"
11
+ @test_relationship1 = ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "demo:10")
12
+ @test_relationship2 = ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_part_of, :object => "demo:11")
13
+ @test_relationship3 = ActiveFedora::Relationship.new(:subject => @pid, :predicate => :has_part, :object => "demo:12")
14
+
15
+ @sample_xml = REXML::Document.new(@sample_xml_string)
16
+ end
17
+
18
+ before(:each) do
19
+ @test_ds = ActiveFedora::RelsExtDatastream.new(:pid => @pid)
20
+ end
21
+
22
+ it "should respond to #new" do
23
+ ActiveFedora::RelsExtDatastream.should respond_to(:new)
24
+ end
25
+
26
+ describe "#new" do
27
+ it "should create a datsatream with DSID of RELS-EXT" do
28
+ test_datastream = ActiveFedora::RelsExtDatastream.new
29
+ test_datastream.dsid.should eql("RELS-EXT")
30
+ end
31
+ end
32
+
33
+ it 'should respond to #save' do
34
+ @test_ds.should respond_to(:save)
35
+ end
36
+
37
+ describe '#save' do
38
+
39
+ it "should call super.save" do
40
+ # Funny jiggering to mock super when RelsExt datstream calls super.save
41
+ Fedora::Repository.instance.expects(:save).returns(mock("boo"))
42
+ @test_ds.save
43
+ end
44
+
45
+ it "should generate new rdf/xml as the datastream content if the object has been changed" do
46
+ @test_ds.dirty = true
47
+ @test_ds.expects(:to_rels_ext)
48
+ @test_ds.expects(:content=)
49
+ # Funny jiggering to mock super when RelsExt datstream calls super.save
50
+ Fedora::Repository.instance.expects(:save).returns(mock("boo"))
51
+ @test_ds.save
52
+ end
53
+
54
+ end
55
+
56
+ describe "#from_xml" do
57
+ before(:all) do
58
+ ActiveFedora::SolrService.register
59
+ @test_obj = ActiveFedora::Base.new
60
+ @test_obj.add_relationship(:is_member_of, "demo:10")
61
+ @test_obj.add_relationship(:is_part_of, "demo:11")
62
+ @test_obj.save
63
+ end
64
+ after(:all) do
65
+ @test_obj.delete
66
+ end
67
+ it "should load RELS-EXT relationships into relationships hash" do
68
+ @test_obj.relationships.should == {:self=>{:is_member_of=>["info:fedora/demo:10"], :is_part_of=>["info:fedora/demo:11"], :has_model=>["info:fedora/afmodel:ActiveFedora_Base"]}}
69
+ doc = REXML::Document.new(@test_obj.inner_object.object_xml)
70
+ el = doc.elements["/foxml:digitalObject//foxml:datastream[@ID='RELS-EXT']"]
71
+ new_ds = ActiveFedora::RelsExtDatastream.new
72
+ new_ds.relationships.should == {:self=>{}}
73
+ ActiveFedora::RelsExtDatastream.from_xml(new_ds,el)
74
+ new_ds.relationships.should == @test_obj.relationships
75
+ end
76
+ end
77
+
78
+
79
+ describe ".to_solr" do
80
+
81
+ it "should provide .to_solr and return a SolrDocument" do
82
+ @test_ds.should respond_to(:to_solr)
83
+ @test_ds.to_solr.should be_kind_of(Solr::Document)
84
+ end
85
+
86
+ it "should serialize the relationships into a Solr::Document" do
87
+ @test_ds.add_relationship(@test_relationship1)
88
+ @test_ds.add_relationship(@test_relationship2)
89
+ @test_ds.add_relationship(@test_relationship3)
90
+ solr_doc = @test_ds.to_solr
91
+ solr_doc[:is_member_of_s].should == "info:fedora/demo:10"
92
+ solr_doc[:is_part_of_s].should == "info:fedora/demo:11"
93
+ solr_doc[:has_part_s].should == "info:fedora/demo:12"
94
+ end
95
+ end
96
+
97
+ it "should treat :self and self.pid as equivalent subjects"
98
+
99
+ end
@@ -0,0 +1,136 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ describe Fedora::Repository do
4
+
5
+ after(:all) do
6
+ Fedora::Repository.register(ActiveFedora.fedora_config[:url])
7
+ end
8
+
9
+ it "should trim extra slash on uri" do
10
+ Fedora::Repository.expects(:new).with('http://bar.baz/bat', nil)
11
+ Fedora::Repository.register('http://bar.baz/bat/')
12
+ Fedora::Repository.expects(:new).with('http://bar.baz/bat', nil)
13
+ Fedora::Repository.register(URI.parse('http://bar.baz/bat/'))
14
+ end
15
+
16
+ it "should accept a url to register" do
17
+ Fedora::Repository.expects(:new).with('http://bar.baz', nil).returns(stub_everything)
18
+ Fedora::Repository.register('http://bar.baz').should_not be_nil
19
+ z = Fedora::Repository.instance
20
+ z.should_not be_nil
21
+ (z === Fedora::Repository.instance).should == true
22
+ end
23
+
24
+ it "should initialize a repo" do
25
+ Fedora::Repository.expects(:new).with('http://foo.bar', nil).returns(stub_everything)
26
+ Fedora::Repository.register('http://foo.bar')
27
+ z = Fedora::Repository.instance
28
+ y = Fedora::Repository.instance
29
+ z.should_not be_nil
30
+ y.should_not be_nil
31
+ (z===y).should == true
32
+ end
33
+
34
+ it 'should be a singleton' do
35
+ Fedora::Repository.expects(:new).with('http://foo.bar',nil).returns(stub_everything)
36
+ Fedora::Repository.register('http://foo.bar')
37
+ a = Fedora::Repository.instance
38
+ b = Fedora::Repository.instance
39
+ (a === b).should == true
40
+ end
41
+
42
+ it "should be able to reserve an id" do
43
+ bodymock = mock('body')
44
+ bodymock.expects(:body).returns <<-EOS
45
+ <?xml version="1.0" encoding="UTF-8"?>
46
+ <pidList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fedora.info/definitions/1/0/management/ http://www.fedora.info/definitions/1/0/objectHistory.xsd">
47
+ <pid>changeme:5035</pid>
48
+ </pidList>
49
+ EOS
50
+
51
+ Fedora::Repository.register('http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora').should_not be_nil
52
+ Fedora::Repository.instance.send(:connection).expects(:post).with('/fedora/management/getNextPID?xml=true').returns(bodymock)
53
+ Fedora::Repository.instance.should_not be_nil
54
+ Fedora::Repository.instance.nextid.should == 'changeme:5035'
55
+ end
56
+
57
+ it "should have attributes corresponding to the info in fedora/describe" do
58
+ Fedora::Repository.register('http://foo.bar')
59
+ #skipping oai_namespace_identifier and oai_delimiter
60
+ %w[repository_name base_url fedora_version pid_namespace pid_delimiter].each do |attribute_name|
61
+ Fedora::Repository.instance.should respond_to(attribute_name)
62
+ Fedora::Repository.instance.should respond_to(attribute_name + "=")
63
+ end
64
+ end
65
+
66
+ describe "export" do
67
+ it "should call fetch_custom with the appropriate parameters" do
68
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:FOXML-1.1", :context=>"archive")
69
+ Fedora::Repository.instance.export("test:my_pid")
70
+ end
71
+ it "should support :foxml, :mets, :atom, and :atom_zip" do
72
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"archive")
73
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOMZip-1.1", :context=>"archive")
74
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:FOXML-1.1", :context=>"archive")
75
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:METSFedoraExt-1.1", :context=>"archive")
76
+
77
+ Fedora::Repository.instance.export("test:my_pid", :format=>:atom)
78
+ Fedora::Repository.instance.export("test:my_pid", :format=>:atom_zip)
79
+ Fedora::Repository.instance.export("test:my_pid", :format=>:foxml)
80
+ Fedora::Repository.instance.export("test:my_pid", :format=>:mets)
81
+ end
82
+ it "should allow you to pass through the format uri as a string" do
83
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOMZip-1.1", :context=>"archive")
84
+ Fedora::Repository.instance.export("test:my_pid", :format=>"info:fedora/fedora-system:ATOMZip-1.1")
85
+ end
86
+ it "should support export context" do
87
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"public").times(2)
88
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"migrate")
89
+ Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"archive")
90
+
91
+ Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>:public)
92
+ Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>"public")
93
+ Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>:migrate)
94
+ Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>:archive)
95
+ end
96
+ end
97
+
98
+ describe "ingest" do
99
+ it "should post the provided xml or file to fedora" do
100
+ foxml = fixture("test_12.foxml.xml").read
101
+ connection = Fedora::Repository.instance.send(:connection)
102
+ connection.expects(:post).with("/fedora/objects/new",foxml)
103
+ Fedora::Repository.instance.ingest(foxml)
104
+ end
105
+ it "should accept a file as its input" do
106
+ foxml_file = fixture("test_12.foxml.xml")
107
+ foxml = fixture("test_12.foxml.xml").read
108
+ connection = Fedora::Repository.instance.send(:connection)
109
+ connection.expects(:post).with("/fedora/objects/new",foxml)
110
+ Fedora::Repository.instance.ingest(foxml_file)
111
+ end
112
+ end
113
+
114
+ describe "#register" do
115
+ after(:all) do
116
+ Fedora::Repository.register(ActiveFedora.fedora_config[:url])
117
+ end
118
+ it "should initialize the attributes from fedora/describe" do
119
+ sample_attrs = {"sampleSearch-URL"=>["http://127.0.0.1:8080/fedora/search"], "repositoryOAI-identifier"=>[{"OAI-sample"=>["oai:example.org:changeme:100"], "OAI-delimiter"=>[":"], "OAI-namespaceIdentifier"=>["example.org"]}], "repositoryBaseURL"=>["http://127.0.0.1:8080/fedora"], "xsi:schemaLocation"=>"http://www.fedora.info/definitions/1/0/access/ http://www.fedora.info/definitions/1/0/fedoraRepository.xsd", "xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema", "repositoryPID"=>[{"PID-sample"=>["changeme:100"], "PID-namespaceIdentifier"=>["changeme"], "PID-delimiter"=>[":"], "retainPID"=>["*"]}], "adminEmail"=>["bob@example.org", "sally@example.org"], "repositoryVersion"=>["3.1"], "sampleOAI-URL"=>["http://localhost:8080/fedora/oai?verb=Identify"], "sampleAccess-URL"=>["http://localhost:8080/fedora/get/demo:5"], "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "repositoryName"=>["Fedora Repository"]}
120
+ Fedora::Repository.any_instance.expects(:describe_repository).returns(sample_attrs)
121
+ Fedora::Repository.register('http://foo.bar')
122
+ boo = Fedora::Repository.instance
123
+ boo.repository_name.should == "Fedora Repository"
124
+ boo.base_url.should == "http://127.0.0.1:8080/fedora"
125
+ boo.fedora_version.should == "3.1"
126
+ boo.pid_namespace.should == "changeme"
127
+ boo.pid_delimiter.should == ":"
128
+ end
129
+ end
130
+
131
+
132
+ it "should provide .describe_repository" do
133
+ Fedora::Repository.instance.should respond_to(:describe_repository)
134
+ end
135
+
136
+ end
@@ -0,0 +1,49 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'ruby-fedora'
4
+
5
+
6
+ describe Fedora::Datastream do
7
+
8
+ before(:each) do
9
+ Fedora::Repository.register(ActiveFedora.fedora_config[:url])
10
+ @test_datastream = Fedora::Datastream.new
11
+ end
12
+
13
+ it "should track the controlgroup attr" do
14
+ td = Fedora::Datastream.new(:controlGroup=>'M')
15
+ td.control_group.should == 'M'
16
+ end
17
+
18
+ it "should provide .url" do
19
+ @test_datastream.should respond_to(:url)
20
+ @test_datastream.expects(:pid).returns("_foo_")
21
+ @test_datastream.url.should == 'http://localhost:8080/fedora/objects/_foo_/datastreams/'
22
+ end
23
+
24
+ describe ".url" do
25
+ it "should return the Repository base_url with /objects/pid appended" do
26
+ Fedora::Repository.instance.expects(:base_url).returns("BASE_URL")
27
+ @test_datastream.expects(:pid).returns("_PID_")
28
+ @test_datastream.expects(:dsid).returns("_DSID_")
29
+ @test_datastream.url.should == "BASE_URL/objects/_PID_/datastreams/_DSID_"
30
+ end
31
+ end
32
+
33
+ describe ".label" do
34
+ it "should return the dsLabel attribute" do
35
+ @test_datastream.label.should == @test_datastream.attributes[:dsLabel]
36
+ end
37
+ end
38
+
39
+ describe ".label=" do
40
+ it "should set the dsLabel attribute" do
41
+ @test_datastream.label.should_not == "Foo dsLabel"
42
+ @test_datastream.attributes[:dsLabel].should_not == "Foo dsLabel"
43
+ @test_datastream.label = "Foo dsLabel"
44
+ @test_datastream.label.should == "Foo dsLabel"
45
+ @test_datastream.attributes[:dsLabel].should == "Foo dsLabel"
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,354 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'active_fedora'
4
+ require 'xmlsimple'
5
+ #require 'mocha'
6
+
7
+ #include ActiveFedora::SemanticNode
8
+ #include Mocha::Standalone
9
+
10
+ describe ActiveFedora::SemanticNode do
11
+
12
+ before(:all) do
13
+ @pid = "test:sample_pid"
14
+ @uri = "info:fedora/#{@pid}"
15
+ @sample_solr_hits = [{"id"=>"_PID1_", "active_fedora_model_s"=>["AudioRecord"]},
16
+ {"id"=>"_PID2_", "active_fedora_model_s"=>["AudioRecord"]},
17
+ {"id"=>"_PID3_", "active_fedora_model_s"=>["AudioRecord"]}]
18
+ end
19
+
20
+ before(:each) do
21
+ class SpecNode
22
+ include ActiveFedora::SemanticNode
23
+ end
24
+ @node = SpecNode.new
25
+ @stub_relationship = stub("mock_relationship", :subject => @pid, :predicate => "isMemberOf", :object => "demo:8", :class => ActiveFedora::Relationship)
26
+ @test_relationship = ActiveFedora::Relationship.new(:subject => @pid, :predicate => "isMemberOf", :object => "demo:9")
27
+ @test_relationship1 = ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "demo:10")
28
+ @test_relationship2 = ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_part_of, :object => "demo:11")
29
+ @test_relationship3 = ActiveFedora::Relationship.new(:subject => @pid, :predicate => :has_part, :object => "demo:12")
30
+ end
31
+
32
+ after(:each) do
33
+ Object.send(:remove_const, :SpecNode)
34
+ end
35
+
36
+ it 'should provide predicate mappings for entire Fedora Relationship Ontology' do
37
+ desired_mappings = Hash[:is_member_of => "isMemberOf",
38
+ :has_member => "hasMember",
39
+ :is_part_of => "isPartOf",
40
+ :has_part => "hasPart",
41
+ :is_member_of_collection => "isMemberOfCollection",
42
+ :has_collection_member => "hasCollectionMember",
43
+ :is_constituent_of => "isConstituentOf",
44
+ :has_constituent => "hasConstituent",
45
+ :is_subset_of => "isSubsetOf",
46
+ :has_subset => "hasSubset",
47
+ :is_derivation_of => "isDerivationOf",
48
+ :has_derivation => "hasDerivation",
49
+ :is_dependent_of => "isDependentOf",
50
+ :has_dependent => "hasDependent",
51
+ :is_description_of => "isDescriptionOf",
52
+ :has_description => "hasDescription",
53
+ :is_metadata_for => "isMetadataFor",
54
+ :has_metadata => "hasMetadata",
55
+ :is_annotation_of => "isAnnotationOf",
56
+ :has_annotation => "hasAnnotation",
57
+ :has_equivalent => "hasEquivalent",
58
+ :conforms_to => "conformsTo"]
59
+ desired_mappings.each_pair do |k,v|
60
+ SpecNode::PREDICATE_MAPPINGS.should have_key(k)
61
+ SpecNode::PREDICATE_MAPPINGS[k].should == v
62
+ end
63
+ end
64
+
65
+ it 'should provide .internal_uri' do
66
+ @node.should respond_to(:internal_uri)
67
+ end
68
+
69
+ it 'should provide #has_relationship' do
70
+ SpecNode.should respond_to(:has_relationship)
71
+ SpecNode.should respond_to(:has_relationship)
72
+ end
73
+
74
+ describe '#has_relationship' do
75
+ it "should create finders based on provided relationship name" do
76
+ SpecNode.has_relationship("parts", :is_part_of, :inbound => true)
77
+ local_node = SpecNode.new
78
+ local_node.should respond_to(:parts_ids)
79
+ # local_node.should respond_to(:parts)
80
+ local_node.should_not respond_to(:containers)
81
+ SpecNode.has_relationship("containers", :is_member_of)
82
+ local_node.should respond_to(:containers_ids)
83
+ end
84
+
85
+ it "should add a subject and predicate to the relationships array" do
86
+ SpecNode.has_relationship("parents", :is_part_of)
87
+ SpecNode.relationships.should have_key(:self)
88
+ @node.relationships[:self].should have_key(:is_part_of)
89
+ end
90
+
91
+ it "should use :inbound as the subject if :inbound => true" do
92
+ SpecNode.has_relationship("parents", :is_part_of, :inbound => true)
93
+ SpecNode.relationships.should have_key(:inbound)
94
+ @node.relationships[:inbound].should have_key(:is_part_of)
95
+ end
96
+
97
+ it 'should create inbound relationship finders' do
98
+ SpecNode.expects(:create_inbound_relationship_finders)
99
+ SpecNode.has_relationship("parts", :is_part_of, :inbound => true)
100
+ end
101
+
102
+ it 'should create outbound relationship finders' do
103
+ SpecNode.expects(:create_outbound_relationship_finders).times(2)
104
+ SpecNode.has_relationship("parts", :is_part_of, :inbound => false)
105
+ SpecNode.has_relationship("container", :is_member_of)
106
+ end
107
+
108
+ it "should create outbound relationship finders that return an array of fedora PIDs" do
109
+ SpecNode.has_relationship("containers", :is_member_of, :inbound => false)
110
+ local_node = SpecNode.new
111
+ local_node.internal_uri = "info:fedora/#{@pid}"
112
+
113
+ local_node.add_relationship(ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/container:A") )
114
+ local_node.add_relationship(ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/container:B") )
115
+ containers_result = local_node.containers_ids
116
+ containers_result.should be_instance_of(Array)
117
+ containers_result.should include("container:A")
118
+ containers_result.should include("container:B")
119
+ end
120
+
121
+ end
122
+
123
+ describe '#create_inbound_relationship_finders' do
124
+
125
+ it 'should respond to #create_inbound_relationship_finders' do
126
+ SpecNode.should respond_to(:create_inbound_relationship_finders)
127
+ end
128
+
129
+ it "should create finders based on provided relationship name" do
130
+ SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
131
+ local_node = SpecNode.new
132
+ local_node.should respond_to(:parts_ids)
133
+ local_node.should_not respond_to(:containers)
134
+ SpecNode.create_inbound_relationship_finders("containers", :is_member_of, :inbound => true)
135
+ local_node.should respond_to(:containers_ids)
136
+ local_node.should respond_to(:containers)
137
+ end
138
+
139
+ it "resulting finder should search against solr and use Model#load_instance to build an array of objects" do
140
+ solr_result = (mock("solr result", :is_a? => true, :hits => @sample_solr_hits))
141
+ mock_repo = mock("repo")
142
+ mock_repo.expects(:find_model).with("_PID1_", "AudioRecord").returns("AR1")
143
+ mock_repo.expects(:find_model).with("_PID2_", "AudioRecord").returns("AR2")
144
+ mock_repo.expects(:find_model).with("_PID3_", "AudioRecord").returns("AR3")
145
+ SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
146
+ local_node = SpecNode.new()
147
+ local_node.expects(:internal_uri).returns("info:fedora/test:sample_pid")
148
+ ActiveFedora::SolrService.instance.conn.expects(:query).with("is_part_of_s:info\\:fedora/test\\:sample_pid").returns(solr_result)
149
+ Fedora::Repository.expects(:instance).returns(mock_repo).times(3)
150
+ Kernel.expects(:const_get).with("AudioRecord").returns("AudioRecord").times(3)
151
+ local_node.parts.should == ["AR1", "AR2", "AR3"]
152
+ end
153
+
154
+ it "resulting finder should accept :solr as :response_format value and return the raw Solr Result" do
155
+ solr_result = mock("solr result")
156
+ SpecNode.create_inbound_relationship_finders("constituents", :is_constituent_of, :inbound => true)
157
+ local_node = SpecNode.new
158
+ mock_repo = mock("repo")
159
+ mock_repo.expects(:find_model).never
160
+ local_node.expects(:internal_uri).returns("info:fedora/test:sample_pid")
161
+ ActiveFedora::SolrService.instance.conn.expects(:query).with("is_constituent_of_s:info\\:fedora/test\\:sample_pid").returns(solr_result)
162
+ local_node.constituents(:response_format => :solr).should equal(solr_result)
163
+ end
164
+
165
+
166
+ it "resulting _ids finder should search against solr and return an array of fedora PIDs" do
167
+ SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
168
+ local_node = SpecNode.new
169
+ local_node.expects(:internal_uri).returns("info:fedora/test:sample_pid")
170
+ ActiveFedora::SolrService.instance.conn.expects(:query).with("is_part_of_s:info\\:fedora/test\\:sample_pid").returns(mock("solr result", :hits => [Hash["id"=>"pid1"], Hash["id"=>"pid2"]]))
171
+ local_node.parts(:response_format => :id_array).should == ["pid1", "pid2"]
172
+ end
173
+
174
+ it "resulting _ids finder should call the basic finder with :result_format => :id_array" do
175
+ SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
176
+ local_node = SpecNode.new
177
+ local_node.expects(:parts).with(:response_format => :id_array)
178
+ local_node.parts_ids
179
+ end
180
+
181
+ it "resulting finder should provide option of filtering results by :type"
182
+ end
183
+
184
+ describe '#create_outbound_relationship_finders' do
185
+
186
+ it 'should respond to #create_outbound_relationship_finders' do
187
+ SpecNode.should respond_to(:create_outbound_relationship_finders)
188
+ end
189
+
190
+ it "should create finders based on provided relationship name" do
191
+ SpecNode.create_outbound_relationship_finders("parts", :is_part_of)
192
+ local_node = SpecNode.new
193
+ local_node.should respond_to(:parts_ids)
194
+ #local_node.should respond_to(:parts) #.with(:type => "AudioRecord")
195
+ local_node.should_not respond_to(:containers)
196
+ SpecNode.create_outbound_relationship_finders("containers", :is_member_of)
197
+ local_node.should respond_to(:containers_ids)
198
+ local_node.should respond_to(:containers)
199
+ end
200
+
201
+ describe " resulting finder" do
202
+ it "should read from relationships array and use Repository.find_model to build an array of objects" do
203
+ SpecNode.create_outbound_relationship_finders("containers", :is_member_of)
204
+ local_node = SpecNode.new
205
+ local_node.expects(:outbound_relationships).returns({:is_member_of => ["my:_PID1_", "my:_PID2_", "my:_PID3_"]}).times(2)
206
+ mock_repo = mock("repo")
207
+ solr_result = mock("solr result", :is_a? => true)
208
+ solr_result.expects(:hits).returns([{"id"=> "my:_PID1_", "active_fedora_model_s" => "SpecNode"}, {"id"=> "my:_PID2_", "active_fedora_model_s" => "SpecNode"}, {"id"=> "my:_PID3_", "active_fedora_model_s" => "SpecNode"}])
209
+ ActiveFedora::SolrService.instance.conn.expects(:query).with("id:my\\:_PID1_ OR id:my\\:_PID2_ OR id:my\\:_PID3_").returns(solr_result)
210
+ mock_repo.expects(:find_model).with("my:_PID1_", SpecNode).returns("AR1")
211
+ mock_repo.expects(:find_model).with("my:_PID2_", SpecNode).returns("AR2")
212
+ mock_repo.expects(:find_model).with("my:_PID3_", SpecNode).returns("AR3")
213
+ Fedora::Repository.expects(:instance).returns(mock_repo).times(3)
214
+ local_node.containers.should == ["AR1", "AR2", "AR3"]
215
+ end
216
+
217
+ it "should accept :solr as :response_format value and return the raw Solr Result" do
218
+ solr_result = mock("solr result")
219
+ SpecNode.create_outbound_relationship_finders("constituents", :is_constituent_of)
220
+ local_node = SpecNode.new
221
+ mock_repo = mock("repo")
222
+ mock_repo.expects(:find_model).never
223
+ local_node.stubs(:internal_uri)
224
+ ActiveFedora::SolrService.instance.conn.expects(:query).returns(solr_result)
225
+ local_node.constituents(:response_format => :solr).should equal(solr_result)
226
+ end
227
+
228
+ it "(:response_format => :id_array) should read from relationships array" do
229
+ SpecNode.create_outbound_relationship_finders("containers", :is_member_of)
230
+ local_node = SpecNode.new
231
+ local_node.expects(:outbound_relationships).returns({:is_member_of => []}).times(2)
232
+ local_node.containers_ids
233
+ end
234
+
235
+ it "(:response_format => :id_array) should return an array of fedora PIDs" do
236
+ SpecNode.create_outbound_relationship_finders("containers", :is_member_of)
237
+ local_node = SpecNode.new
238
+ local_node.add_relationship(@test_relationship1)
239
+ result = local_node.containers_ids
240
+ puts local_node.relationships.inspect
241
+ #puts local_node.outbound_relationships.inspect
242
+ puts local_node.internal_uri
243
+ result.should be_instance_of(Array)
244
+ result.should include("demo:10")
245
+ end
246
+
247
+ it "should provide option of filtering results by :type"
248
+ end
249
+
250
+ describe " resulting _ids finder" do
251
+ it "should call the basic finder with :result_format => :id_array" do
252
+ SpecNode.create_outbound_relationship_finders("parts", :is_part_of)
253
+ local_node = SpecNode.new
254
+ local_node.expects(:parts).with(:response_format => :id_array)
255
+ local_node.parts_ids
256
+ end
257
+ end
258
+ end
259
+
260
+ describe ".add_relationship" do
261
+ it "should add relationship to the relationships hash" do
262
+ @node.add_relationship(@test_relationship)
263
+ @node.relationships.should have_key(@test_relationship.subject)
264
+ @node.relationships[@test_relationship.subject].should have_key(@test_relationship.predicate)
265
+ @node.relationships[@test_relationship.subject][@test_relationship.predicate].should include(@test_relationship.object)
266
+ end
267
+
268
+ it "adding relationship to an instance should not affect class-level relationships hash" do
269
+ local_test_node1 = SpecNode.new
270
+ local_test_node2 = SpecNode.new
271
+ local_test_node1.add_relationship(@test_relationship1)
272
+ #local_test_node2.add_relationship(@test_relationship2)
273
+
274
+ local_test_node1.relationships[:self][:is_member_of].should == ["info:fedora/demo:10"]
275
+ local_test_node2.relationships[:self][:is_member_of].should be_nil
276
+ end
277
+
278
+ end
279
+
280
+ describe '#relationships' do
281
+
282
+ it "should return a hash" do
283
+ SpecNode.relationships.class.should == Hash
284
+ end
285
+
286
+ end
287
+
288
+
289
+ it "should provide a relationship setter"
290
+ it "should provide a relationship getter"
291
+ it "should provide a relationship deleter"
292
+
293
+ describe '.register_triple' do
294
+ it 'should add triples to the relationships hash' do
295
+ @node.register_triple(:self, :is_part_of, "info:fedora/demo:10")
296
+ @node.register_triple(:self, :is_member_of, "info:fedora/demo:11")
297
+ @node.relationships[:self].should have_key(:is_part_of)
298
+ @node.relationships[:self].should have_key(:is_member_of)
299
+ @node.relationships[:self][:is_part_of].should include("info:fedora/demo:10")
300
+ @node.relationships[:self][:is_member_of].should include("info:fedora/demo:11")
301
+ end
302
+
303
+ it "should not be a class level method"
304
+ end
305
+
306
+ it 'should provide #predicate_lookup that maps symbols to common RELS-EXT predicates' do
307
+ SpecNode.should respond_to(:predicate_lookup)
308
+ SpecNode.predicate_lookup(:is_part_of).should == "isPartOf"
309
+ SpecNode.predicate_lookup(:is_member_of).should == "isMemberOf"
310
+ SpecNode.predicate_lookup("isPartOfCollection").should == "isPartOfCollection"
311
+ end
312
+
313
+ it 'should provide #relationships_to_rels_ext' do
314
+ SpecNode.should respond_to(:relationships_to_rels_ext)
315
+ @node.should respond_to(:to_rels_ext)
316
+ end
317
+
318
+ describe '#relationships_to_rels_ext' do
319
+
320
+ before(:all) do
321
+ @sample_rels_ext_xml = <<-EOS
322
+ <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
323
+ <rdf:Description rdf:about='info:fedora/test:sample_pid'>
324
+ <isMemberOf rdf:resource='info:fedora/demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/>
325
+ <isPartOf rdf:resource='info:fedora/demo:11' xmlns='info:fedora/fedora-system:def/relations-external#'/>
326
+ <hasPart rdf:resource='info:fedora/demo:12' xmlns='info:fedora/fedora-system:def/relations-external#'/>
327
+ </rdf:Description>
328
+ </rdf:RDF>
329
+ EOS
330
+ end
331
+
332
+ it 'should serialize the relationships array to Fedora RELS-EXT rdf/xml' do
333
+ @node.add_relationship(@test_relationship1)
334
+ @node.add_relationship(@test_relationship2)
335
+ @node.add_relationship(@test_relationship3)
336
+ @node.internal_uri = @uri
337
+ returned_xml = XmlSimple.xml_in(@node.to_rels_ext(@pid))
338
+ returned_xml.should == XmlSimple.xml_in(@sample_rels_ext_xml)
339
+ end
340
+
341
+ it "should treat :self and self.pid as equivalent subjects"
342
+ end
343
+
344
+ it 'should provide #relationships_to_rdf_xml'
345
+
346
+ describe '#relationships_to_rdf_xml' do
347
+ it 'should serialize the relationships array to rdf/xml'
348
+ end
349
+
350
+ it "should provide .outbound_relationships" do
351
+ @node.should respond_to(:outbound_relationships)
352
+ end
353
+
354
+ end