ruby-fs-stack 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +26 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/examples/familytree_example.rb +26 -0
- data/examples/login_example.rb +11 -0
- data/lib/ruby-fs-stack/assets/entrust-ca.crt +104 -0
- data/lib/ruby-fs-stack/enunciate/LICENSE +15 -0
- data/lib/ruby-fs-stack/enunciate/README +6 -0
- data/lib/ruby-fs-stack/enunciate/familytree.rb +12608 -0
- data/lib/ruby-fs-stack/enunciate/identity.rb +964 -0
- data/lib/ruby-fs-stack/familytree.rb +827 -0
- data/lib/ruby-fs-stack/fs_communicator.rb +109 -0
- data/lib/ruby-fs-stack/fs_utils.rb +27 -0
- data/lib/ruby-fs-stack/identity.rb +45 -0
- data/lib/ruby-fs-stack/warning_suppressor.rb +18 -0
- data/lib/ruby-fs-stack.rb +2 -0
- data/spec/communicator_spec.rb +214 -0
- data/spec/familytree_v2/familytree_communicator_spec.rb +309 -0
- data/spec/familytree_v2/json/match_KW3B-NNM.js +1 -0
- data/spec/familytree_v2/json/person/KJ86-3VD_all.js +1 -0
- data/spec/familytree_v2/json/person/KJ86-3VD_version.js +1 -0
- data/spec/familytree_v2/json/person/post_response.js +1 -0
- data/spec/familytree_v2/json/person/relationship_not_found.js +1 -0
- data/spec/familytree_v2/json/person/relationship_read.js +1 -0
- data/spec/familytree_v2/json/person/relationship_update.js +1 -0
- data/spec/familytree_v2/json/search.js +1 -0
- data/spec/familytree_v2/person_spec.rb +563 -0
- data/spec/familytree_v2/search_results_spec.rb +131 -0
- data/spec/fs_utils_spec.rb +33 -0
- data/spec/identity_v1/identity_spec.rb +50 -0
- data/spec/identity_v1/json/login.js +1 -0
- data/spec/ruby-fs-stack_spec.rb +6 -0
- data/spec/spec_helper.rb +27 -0
- metadata +119 -0
@@ -0,0 +1,563 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'ruby-fs-stack/familytree'
|
3
|
+
|
4
|
+
|
5
|
+
describe Org::Familysearch::Ws::Familytree::V2::Schema::Person do
|
6
|
+
def new_person
|
7
|
+
Org::Familysearch::Ws::Familytree::V2::Schema::Person.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse_person(filename = 'KJ86-3VD_all.js')
|
11
|
+
fname = File.join(File.dirname(__FILE__),'json','person',filename)
|
12
|
+
json_hash = JSON.parse(File.read(fname))
|
13
|
+
familytree = Org::Familysearch::Ws::Familytree::V2::Schema::FamilyTree.from_json(json_hash)
|
14
|
+
familytree.persons[0]
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_assertions(person = nil)
|
18
|
+
person ||= @person
|
19
|
+
person.assertions = Org::Familysearch::Ws::Familytree::V2::Schema::PersonAssertions.new
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "convenience access methods" do
|
23
|
+
|
24
|
+
describe "gender" do
|
25
|
+
|
26
|
+
describe "for persons with gender assertions" do
|
27
|
+
before(:each) do
|
28
|
+
@person = parse_person
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return the first gender value" do
|
32
|
+
@person.gender.should == 'Male'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "for nil genders or assertions" do
|
37
|
+
before(:each) do
|
38
|
+
@person = parse_person('KJ86-3VD_version.js')
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_genders_array
|
42
|
+
@person.assertions.genders = []
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return nil if no assertions" do
|
46
|
+
@person.gender.should == nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return nil if no genders" do
|
50
|
+
add_assertions
|
51
|
+
@person.gender.should == nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return nil if genders is empty" do
|
55
|
+
add_assertions
|
56
|
+
add_genders_array
|
57
|
+
@person.gender.should == nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return nil if genders[0].value is nil" do
|
61
|
+
add_assertions
|
62
|
+
add_genders_array
|
63
|
+
@person.assertions.genders << stub('GenderAssertion', {:value => nil})
|
64
|
+
@person.gender.should == nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "full_names" do
|
71
|
+
describe "for persons with at least one name" do
|
72
|
+
before(:each) do
|
73
|
+
@person = parse_person
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return an array of strings" do
|
77
|
+
names = @person.full_names
|
78
|
+
names.should be_a_kind_of(Array)
|
79
|
+
names[0].should be_a_kind_of(String)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return an array of names" do
|
83
|
+
names = @person.full_names
|
84
|
+
names.first.should == "Parker Felch"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return a name pieced together from pieces" do
|
88
|
+
@person.add_name("Parker James /Felch/")
|
89
|
+
names = @person.full_names
|
90
|
+
names[3].should == "Parker James Felch"
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "full_name" do
|
94
|
+
|
95
|
+
it "should return the first name" do
|
96
|
+
@person.full_name.should == "Parker Felch"
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "for persons without names" do
|
103
|
+
|
104
|
+
def add_names_array
|
105
|
+
@person.assertions.names = []
|
106
|
+
end
|
107
|
+
|
108
|
+
before(:each) do
|
109
|
+
@person = parse_person('KJ86-3VD_version.js')
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return [] if no assertions" do
|
113
|
+
@person.full_names.should == []
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return [] if no names" do
|
117
|
+
add_assertions
|
118
|
+
@person.full_names.should == []
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return [] if names is empty" do
|
122
|
+
add_assertions
|
123
|
+
add_names_array
|
124
|
+
@person.full_names.should == []
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "births" do
|
132
|
+
describe "for persons with at least one birth event" do
|
133
|
+
before(:each) do
|
134
|
+
@person = parse_person
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should return an array of the birth events" do
|
138
|
+
births = @person.births
|
139
|
+
births.should be_a_kind_of(Array)
|
140
|
+
births.each do |e|
|
141
|
+
e.value.type.should == 'Birth'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "for persons without a birth" do
|
147
|
+
def add_events_array
|
148
|
+
@person.assertions.names = []
|
149
|
+
end
|
150
|
+
|
151
|
+
before(:each) do
|
152
|
+
@person = parse_person('KJ86-3VD_version.js')
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should return [] if no assertions" do
|
156
|
+
@person.births.should == []
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return [] if no events" do
|
160
|
+
add_assertions
|
161
|
+
@person.births.should == []
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should return [] if no events of type Birth are found" do
|
165
|
+
add_assertions
|
166
|
+
add_events_array
|
167
|
+
@person.births.should == []
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "birth" do
|
175
|
+
|
176
|
+
before(:each) do
|
177
|
+
@person = parse_person
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should return the 'selected' birth if an assertion is selected" do
|
181
|
+
pending
|
182
|
+
@person.births[1].selected = true
|
183
|
+
@person.birth.should == @person.births[1]
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should return the first birth if no assertions are selected" do
|
187
|
+
@person.birth.should == @person.births[0]
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should return nil if no births" do
|
191
|
+
@person = parse_person('KJ86-3VD_version.js')
|
192
|
+
@person.birth.should == nil
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "deaths" do
|
197
|
+
describe "for persons with at least one death event" do
|
198
|
+
before(:each) do
|
199
|
+
@person = parse_person
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should return an array of the death events" do
|
203
|
+
deaths = @person.deaths
|
204
|
+
deaths.should be_a_kind_of(Array)
|
205
|
+
deaths.each do |e|
|
206
|
+
e.value.type.should == 'Death'
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "for persons without a death" do
|
212
|
+
def add_events_array
|
213
|
+
@person.assertions.events = []
|
214
|
+
end
|
215
|
+
|
216
|
+
before(:each) do
|
217
|
+
@person = parse_person('KJ86-3VD_version.js')
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should return [] if no assertions" do
|
221
|
+
@person.deaths.should == []
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should return [] if no events" do
|
225
|
+
add_assertions
|
226
|
+
@person.deaths.should == []
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should return [] if no events of type Death are found" do
|
230
|
+
add_assertions
|
231
|
+
add_events_array
|
232
|
+
@person.deaths.should == []
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
describe "death" do
|
240
|
+
|
241
|
+
before(:each) do
|
242
|
+
@person = parse_person
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should return the 'selected' death if an assertion is selected" do
|
246
|
+
pending
|
247
|
+
@person.deaths[1].selected = true
|
248
|
+
@person.death.should == @person.deaths[1]
|
249
|
+
end
|
250
|
+
|
251
|
+
it "should return the first death if no assertions are selected" do
|
252
|
+
@person.death.should == @person.deaths[0]
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should return nil if no deaths" do
|
256
|
+
@person = parse_person('KJ86-3VD_version.js')
|
257
|
+
@person.death.should == nil
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe "baptisms" do
|
262
|
+
describe "for persons with at least one baptism" do
|
263
|
+
before(:each) do
|
264
|
+
@person = parse_person
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should return an array of the baptism" do
|
268
|
+
baptisms = @person.baptisms
|
269
|
+
baptisms.should be_a_kind_of(Array)
|
270
|
+
baptisms.each do |e|
|
271
|
+
e.value.type.should == 'Baptism'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "for persons without a baptism" do
|
277
|
+
def add_ordinances_array
|
278
|
+
@person.assertions.ordinances = []
|
279
|
+
end
|
280
|
+
|
281
|
+
before(:each) do
|
282
|
+
@person = parse_person('KJ86-3VD_version.js')
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should return [] if no assertions" do
|
286
|
+
@person.baptisms.should == []
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should return [] if no ordinances" do
|
290
|
+
add_assertions
|
291
|
+
@person.baptisms.should == []
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should return [] if no ordinances of type Baptism are found" do
|
295
|
+
add_assertions
|
296
|
+
add_ordinances_array
|
297
|
+
@person.baptisms.should == []
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
describe "confirmations" do
|
305
|
+
describe "for persons with at least one confirmation" do
|
306
|
+
before(:each) do
|
307
|
+
@person = parse_person
|
308
|
+
end
|
309
|
+
|
310
|
+
it "should return an array of the confirmation" do
|
311
|
+
confirmations = @person.confirmations
|
312
|
+
confirmations.should be_a_kind_of(Array)
|
313
|
+
confirmations.each do |e|
|
314
|
+
e.value.type.should == 'Confirmation'
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
describe "for persons without a confirmation" do
|
320
|
+
def add_ordinances_array
|
321
|
+
@person.assertions.ordinances = []
|
322
|
+
end
|
323
|
+
|
324
|
+
before(:each) do
|
325
|
+
@person = parse_person('KJ86-3VD_version.js')
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should return [] if no assertions" do
|
329
|
+
@person.confirmations.should == []
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should return [] if no ordinances" do
|
333
|
+
add_assertions
|
334
|
+
@person.confirmations.should == []
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should return [] if no ordinances of type Confirmation are found" do
|
338
|
+
add_assertions
|
339
|
+
add_ordinances_array
|
340
|
+
@person.confirmations.should == []
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
describe "initiatories" do
|
348
|
+
describe "for persons with at least one confirmation" do
|
349
|
+
before(:each) do
|
350
|
+
@person = parse_person
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should return an array of the confirmation" do
|
354
|
+
initiatories = @person.initiatories
|
355
|
+
initiatories.should be_a_kind_of(Array)
|
356
|
+
initiatories.each do |e|
|
357
|
+
e.value.type.should == 'Initiatory'
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe "for persons without a confirmation" do
|
363
|
+
def add_ordinances_array
|
364
|
+
@person.assertions.ordinances = []
|
365
|
+
end
|
366
|
+
|
367
|
+
before(:each) do
|
368
|
+
@person = parse_person('KJ86-3VD_version.js')
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should return [] if no assertions" do
|
372
|
+
@person.initiatories.should == []
|
373
|
+
end
|
374
|
+
|
375
|
+
it "should return [] if no ordinances" do
|
376
|
+
add_assertions
|
377
|
+
@person.initiatories.should == []
|
378
|
+
end
|
379
|
+
|
380
|
+
it "should return [] if no ordinances of type Initiatory are found" do
|
381
|
+
add_assertions
|
382
|
+
add_ordinances_array
|
383
|
+
@person.initiatories.should == []
|
384
|
+
end
|
385
|
+
|
386
|
+
end
|
387
|
+
|
388
|
+
end
|
389
|
+
|
390
|
+
describe "endowments" do
|
391
|
+
describe "for persons with at least one confirmation" do
|
392
|
+
before(:each) do
|
393
|
+
@person = parse_person
|
394
|
+
end
|
395
|
+
|
396
|
+
it "should return an array of the confirmation" do
|
397
|
+
endowments = @person.endowments
|
398
|
+
endowments.should be_a_kind_of(Array)
|
399
|
+
endowments.each do |e|
|
400
|
+
e.value.type.should == 'Endowment'
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
describe "for persons without a confirmation" do
|
406
|
+
def add_ordinances_array
|
407
|
+
@person.assertions.ordinances = []
|
408
|
+
end
|
409
|
+
|
410
|
+
before(:each) do
|
411
|
+
@person = parse_person('KJ86-3VD_version.js')
|
412
|
+
end
|
413
|
+
|
414
|
+
it "should return [] if no assertions" do
|
415
|
+
@person.endowments.should == []
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should return [] if no ordinances" do
|
419
|
+
add_assertions
|
420
|
+
@person.endowments.should == []
|
421
|
+
end
|
422
|
+
|
423
|
+
it "should return [] if no ordinances of type Endowment are found" do
|
424
|
+
add_assertions
|
425
|
+
add_ordinances_array
|
426
|
+
@person.endowments.should == []
|
427
|
+
end
|
428
|
+
|
429
|
+
end
|
430
|
+
|
431
|
+
end
|
432
|
+
|
433
|
+
end
|
434
|
+
|
435
|
+
describe "convenience methods for adding data" do
|
436
|
+
before(:each) do
|
437
|
+
@person = new_person
|
438
|
+
end
|
439
|
+
|
440
|
+
it "should provide easy access method for adding a new gender assertion" do
|
441
|
+
@person.add_gender "Male"
|
442
|
+
@person.gender.should eql("Male")
|
443
|
+
@person = new_person
|
444
|
+
@person.add_gender "Female"
|
445
|
+
@person.gender.should == 'Female'
|
446
|
+
end
|
447
|
+
|
448
|
+
it "should provide easy access method for adding a new name" do
|
449
|
+
@person.add_name "Francis Zimmerman"
|
450
|
+
@person.full_names.should include("Francis Zimmerman")
|
451
|
+
end
|
452
|
+
|
453
|
+
it "should parse the last name and given name and add them to the name pieces" do
|
454
|
+
name = "John Parker /Felch/"
|
455
|
+
@person.add_name name
|
456
|
+
name_form = @person.assertions.names[0].value.forms[0]
|
457
|
+
name_form.pieces.size.should == 3
|
458
|
+
name_form.pieces.first.value.should eql('John')
|
459
|
+
name_form.pieces[1].value.should eql('Parker')
|
460
|
+
name_form.pieces[2].value.should eql('Felch')
|
461
|
+
name_form.pieces[2].type.should eql('Family')
|
462
|
+
end
|
463
|
+
|
464
|
+
it "should provide easy access methods for assigning birth" do
|
465
|
+
place = "Tuscarawas, Ohio, United States"
|
466
|
+
date = "15 Jan 1844"
|
467
|
+
@person.add_birth :place => place, :date => date
|
468
|
+
@person.birth.value.date.original.should eql(date)
|
469
|
+
@person.birth.value.place.original.should eql(place)
|
470
|
+
end
|
471
|
+
|
472
|
+
it "should provide easy access methods for assigning death" do
|
473
|
+
place = "Tuscarawas, Ohio, United States"
|
474
|
+
date = "16 Jan 1855"
|
475
|
+
@person.add_death :place => place, :date => date
|
476
|
+
@person.death.value.place.original.should eql(place)
|
477
|
+
@person.death.value.date.original.should eql("16 Jan 1855")
|
478
|
+
end
|
479
|
+
|
480
|
+
it "should provide easy access methods for writing LDS ordinances" do
|
481
|
+
date = "16 Jan 2009"
|
482
|
+
temple = "SGEOR"
|
483
|
+
place = "St. George, Utah, United States"
|
484
|
+
|
485
|
+
#baptisms
|
486
|
+
@person.add_baptism :date => date, :temple => temple, :place => place
|
487
|
+
@person.baptisms.size.should == 1
|
488
|
+
@person.baptisms.first.value.date.original.should == date
|
489
|
+
@person.baptisms.first.value.temple.should == temple
|
490
|
+
@person.baptisms.first.value.place.original.should == place
|
491
|
+
|
492
|
+
#confirmations
|
493
|
+
@person.add_confirmation :date => date, :temple => temple, :place => place
|
494
|
+
@person.confirmations.size.should == 1
|
495
|
+
@person.confirmations.first.value.date.original.should == date
|
496
|
+
@person.confirmations.first.value.temple.should == temple
|
497
|
+
@person.confirmations.first.value.place.original.should == place
|
498
|
+
|
499
|
+
#initiatory
|
500
|
+
@person.add_initiatory :date => date, :temple => temple, :place => place
|
501
|
+
@person.initiatories.size.should == 1
|
502
|
+
@person.initiatories.first.value.date.original.should == date
|
503
|
+
@person.initiatories.first.value.temple.should == temple
|
504
|
+
@person.initiatories.first.value.place.original.should == place
|
505
|
+
|
506
|
+
#endowment
|
507
|
+
@person.add_endowment :date => date, :temple => temple, :place => place
|
508
|
+
@person.endowments.size.should == 1
|
509
|
+
@person.endowments.first.value.date.original.should == date
|
510
|
+
@person.endowments.first.value.temple.should == temple
|
511
|
+
@person.endowments.first.value.place.original.should == place
|
512
|
+
|
513
|
+
#sealing_to_parents
|
514
|
+
@person.add_sealing_to_parents :date => date, :temple => temple, :place => place, :mother => 'KWQS-BBR', :father => 'KWQS-BBQ'
|
515
|
+
@person.sealing_to_parents.size.should == 1
|
516
|
+
@person.sealing_to_parents.first.value.date.original.should == date
|
517
|
+
@person.sealing_to_parents.first.value.temple.should == temple
|
518
|
+
@person.sealing_to_parents.first.value.place.original.should == place
|
519
|
+
@person.sealing_to_parents.first.value.parents.size.should == 2
|
520
|
+
@person.sealing_to_parents.first.value.parents.find{|p|p.gender == 'Male'}.id.should == 'KWQS-BBQ'
|
521
|
+
@person.sealing_to_parents.first.value.parents.find{|p|p.gender == 'Female'}.id.should == 'KWQS-BBR'
|
522
|
+
@person.sealing_to_parents.first.value.type.should == "Sealing_to_Parents"
|
523
|
+
|
524
|
+
#sealing_to_spouse
|
525
|
+
@person.create_relationship :type => 'spouse', :with => 'KWQS-BBR', :ordinance => {:date => date, :temple => temple, :place => place, :type => "Sealing_to_Spouse"}
|
526
|
+
@person.sealing_to_spouses('KWQS-BBR').size.should == 1
|
527
|
+
sts = @person.sealing_to_spouses('KWQS-BBR')
|
528
|
+
sts.first.value.type.should == "Sealing_to_Spouse"
|
529
|
+
sts.first.value.date.original.should == date
|
530
|
+
sts.first.value.temple.should == temple
|
531
|
+
sts.first.value.place.original.should == place
|
532
|
+
end
|
533
|
+
|
534
|
+
it "should be able to build a relationship write request for a parent relationship" do
|
535
|
+
@person.create_relationship :type => 'parent', :with => 'KWQS-BBR', :lineage => 'Biological'
|
536
|
+
@person.relationships.parents.size.should == 1
|
537
|
+
@person.relationships.parents[0].id.should == 'KWQS-BBR'
|
538
|
+
@person.relationships.parents[0].assertions.characteristics[0].value.lineage.should == 'Biological'
|
539
|
+
@person.relationships.parents[0].assertions.characteristics[0].value.type.should == 'Lineage'
|
540
|
+
end
|
541
|
+
|
542
|
+
it "should be able to build a relationship write request for a spouse relationship" do
|
543
|
+
@person.create_relationship :type => 'spouse', :with => 'KWQS-BBZ'
|
544
|
+
@person.relationships.spouses.size.should == 1
|
545
|
+
@person.relationships.spouses[0].id.should == 'KWQS-BBZ'
|
546
|
+
@person.relationships.spouses[0].assertions.exists[0].value.should be_instance_of(Org::Familysearch::Ws::Familytree::V2::Schema::ExistsValue)
|
547
|
+
end
|
548
|
+
|
549
|
+
it "should be able to build a relationship write request for a spouse relationship" do
|
550
|
+
@person.create_relationship :type => 'spouse', :with => 'KWQS-BBZ', :event => {:type => 'Marriage',:place =>"Utah, United States", :date => '15 Nov 2007'}
|
551
|
+
@person.relationships.spouses.size.should == 1
|
552
|
+
@person.relationships.spouses[0].id.should == 'KWQS-BBZ'
|
553
|
+
@person.relationships.spouses[0].assertions.events[0].value.type.should == 'Marriage'
|
554
|
+
@person.relationships.spouses[0].assertions.events[0].value.date.original.should == '15 Nov 2007'
|
555
|
+
@person.relationships.spouses[0].assertions.events[0].value.place.original.should == 'Utah, United States'
|
556
|
+
@person.relationships.spouses[0].assertions.exists[0].value.should be_instance_of(Org::Familysearch::Ws::Familytree::V2::Schema::ExistsValue)
|
557
|
+
@person.create_relationship :type => 'spouse', :with => 'KWQS-BBZ', :event => {:type => 'Marriage',:place =>"Utah, United States", :date => '15 Nov 2007'}
|
558
|
+
@person.relationships.spouses[0].assertions.events.size.should == 2
|
559
|
+
end
|
560
|
+
|
561
|
+
end
|
562
|
+
|
563
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'ruby-fs-stack/familytree'
|
3
|
+
|
4
|
+
|
5
|
+
describe Org::Familysearch::Ws::Familytree::V2::Schema::SearchResults do
|
6
|
+
FamilyTreeV2 = Org::Familysearch::Ws::Familytree::V2::Schema
|
7
|
+
|
8
|
+
def read_file(filename)
|
9
|
+
fname = File.join(File.dirname(__FILE__),'json',filename)
|
10
|
+
File.read(fname)
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
json = read_file("search.js")
|
15
|
+
familytree = FamilyTreeV2::FamilyTree.from_json JSON.parse(json)
|
16
|
+
@search_results = familytree.searches[0]
|
17
|
+
@results = @search_results.results
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should parse an json string and give us SearchResults" do
|
21
|
+
@search_results.should be_instance_of(FamilyTreeV2::SearchResults)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have 40 results" do
|
25
|
+
@search_results.count.should == 40
|
26
|
+
@search_results.results.should have(40).things
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have first result with ref of KW3B-NNM" do
|
30
|
+
@results.first.id.should eql('KW3B-NNM')
|
31
|
+
# alias ref for backwards compatibility w/ v1
|
32
|
+
@results.first.ref.should eql('KW3B-NNM')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have first result with a score of 5.0" do
|
36
|
+
@search_results.results.first.score.should eql(5.0)
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "first result person" do
|
40
|
+
before(:each) do
|
41
|
+
result = @results.first
|
42
|
+
@person = result.person
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have name of John Flack" do
|
46
|
+
@person.full_name.should eql('John Flack')
|
47
|
+
# aliased name on SearchPerson for backwards compatibility w/ v1
|
48
|
+
@person.name.should == 'John Flack'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be male" do
|
52
|
+
@person.gender.should eql('Male')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have 3 events" do
|
56
|
+
@person.events.should have(3).things
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have birth date of 5 June 1880" do
|
60
|
+
# differs from v1 in that you must explicitly request the original
|
61
|
+
@person.birth.date.original.should eql('5 June 1880')
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have birth place of Arizona, United States" do
|
65
|
+
@person.birth.place.original.should eql('Arizona, United States')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should have death date of 28 Sep 1900" do
|
69
|
+
@person.death.date.original.should eql('16 August 1952')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have death place of Mesa, Maricopa, Arizona, United States" do
|
73
|
+
@person.events.to_json
|
74
|
+
@person.death.place.original.should eql('Mesa, Maricopa, Arizona, United States')
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "first result person's father" do
|
80
|
+
before(:each) do
|
81
|
+
result = @results.first
|
82
|
+
@person = result.father
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should have name of Alfred Flack" do
|
86
|
+
@person.name.should eql('Alfred Flack')
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should be male" do
|
90
|
+
@person.gender.should eql('Male')
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "first result person's mother" do
|
96
|
+
before(:each) do
|
97
|
+
result = @results.first
|
98
|
+
@person = result.mother
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should have name of Sarah Lunt" do
|
102
|
+
@person.name.should eql('Sarah Lunt')
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should be male" do
|
106
|
+
@person.gender.should eql('Female')
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "first result first spouse" do
|
112
|
+
before(:each) do
|
113
|
+
result = @results.first
|
114
|
+
@person = result.spouses.first
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should have name of Jane Littleton" do
|
118
|
+
@person.name.should eql('Jane Littleton')
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should be female" do
|
122
|
+
@person.gender.should eql('Female')
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should respond to marriage, but return nil" do
|
126
|
+
@person.should respond_to(:marriage)
|
127
|
+
@person.marriage.should be_nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|