bible_reference_parser 0.1.1

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.
@@ -0,0 +1,411 @@
1
+ require 'spec_helper'
2
+
3
+ include BibleReferenceParser
4
+
5
+ describe ChapterReference do
6
+
7
+ it_should_behave_like "it tracks errors", ChapterReference.new(1, "1-10,15"), ChapterReference.new(0)
8
+
9
+ describe "initialization" do
10
+
11
+ it "should set the 'metadata' field" do
12
+ metadata = BibleMetadata["Genesis"]
13
+ chapter = ChapterReference.new 1, "10-12", metadata
14
+ chapter.metadata.should eql metadata
15
+ end
16
+
17
+ context "for a valid chapter" do
18
+ before :each do
19
+ @number = 10
20
+ @raw = "10-12"
21
+ @chapter = ChapterReference.new @number, @raw
22
+ end
23
+
24
+ it "should set the 'number' field" do
25
+ @chapter.number.should eql @number
26
+ end
27
+
28
+ it "should set the 'raw_content' field" do
29
+ @chapter.raw_content.should eql @raw
30
+ end
31
+
32
+ it "should parse it's raw_content" do
33
+ @chapter.verse_references.length.should eql 3
34
+ @chapter.verse_references.first.number.should eql 10
35
+ end
36
+
37
+ it "should convert a string chapter number to an integer" do
38
+ chapter = ChapterReference.new "10"
39
+ chapter.number.should eql 10
40
+ end
41
+ end
42
+
43
+ context "for an invalid chapter" do
44
+ it "should set an error for a chapter number equal to 0" do
45
+ chapter = ChapterReference.new 0
46
+ chapter.errors.first.should eql "The chapter number '0' is not valid"
47
+ end
48
+
49
+ it "should set an error for a chapter number below 0" do
50
+ chapter = ChapterReference.new -5
51
+ chapter.errors.first.should eql "The chapter number '-5' is not valid"
52
+ end
53
+
54
+ it "should set an error if the chapter doesn't exist for the book" do
55
+ chapter = ChapterReference.new 51, "10-12", BibleMetadata["Genesis"]
56
+ chapter.errors.first.should eql "Chapter '51' does not exist for the book Genesis"
57
+ end
58
+
59
+ it "should not set the number field" do
60
+ chapter = ChapterReference.new "invalid"
61
+ chapter.number.should be_nil
62
+ end
63
+
64
+ it "should not set the raw_content field" do
65
+ chapter = ChapterReference.new "invalid"
66
+ chapter.raw_content.should be_nil
67
+ end
68
+
69
+ it "should not parse its raw_content for invalid chapters" do
70
+ chapter = ChapterReference.new 0
71
+ chapter.verse_references.should be_nil
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "the valid_reference? method" do
77
+ it "should be true if the chapter number is valid" do
78
+ chapter = ChapterReference.new 1
79
+ chapter.should be_valid_reference
80
+ end
81
+
82
+ it "should be false if the chapter number is not valid" do
83
+ chapter = ChapterReference.new 0
84
+ chapter.should_not be_valid_reference
85
+ end
86
+ end
87
+
88
+ describe "the 'parse_contents' method" do
89
+ it "should set the verse_references field" do
90
+ chapter = ChapterReference.new 1, "1-10"
91
+ chapter.parse_contents
92
+ chapter.verse_references.should_not be_nil
93
+ end
94
+ end
95
+
96
+ describe "when parsing the chapters in a passage" do
97
+
98
+ describe "the parse_chapters method" do
99
+ it "should recognize the chapters in a simple string" do
100
+ chapters = ChapterReference.parse_chapters "1:10"
101
+ chapters.length.should eql 1
102
+ chapters.first.number.should eql 1
103
+ end
104
+
105
+ it "should recognize chapters with spaces" do
106
+ chapters = ChapterReference.parse_chapters "1:1, 2:1, 3:1"
107
+ chapters.length.should eql 3
108
+ end
109
+
110
+ it "should recognize chapters without spaces" do
111
+ chapters = ChapterReference.parse_chapters "1:1,2:1,3:1"
112
+ chapters.length.should eql 3
113
+ end
114
+
115
+ it "should recognize 5 chapters" do
116
+ chapters = ChapterReference.parse_chapters "1:10, 2:20, 3:30, 4:4-10, 5:6-10"
117
+ chapters.length.should eql 5
118
+ end
119
+
120
+ it "should recognize chapters that don't have any verses defined" do
121
+ chapters = ChapterReference.parse_chapters "1, 2, 3, 4, 5, 6, 7, 8"
122
+ chapters.length.should eql 8
123
+ chapters[0].number.should eql 1
124
+ chapters[1].number.should eql 2
125
+ chapters[2].number.should eql 3
126
+ chapters[3].number.should eql 4
127
+ chapters[4].number.should eql 5
128
+ chapters[5].number.should eql 6
129
+ chapters[6].number.should eql 7
130
+ chapters[7].number.should eql 8
131
+ end
132
+
133
+ it "should recognize a new chapter after a semi-colon" do
134
+ chapters = ChapterReference.parse_chapters "1:1,5,10;12"
135
+ chapters.length.should eql 2
136
+ chapters.first.number.should eql 1
137
+ chapters.first.raw_content.should eql "1,5,10"
138
+ chapters.last.number.should eql 12
139
+ chapters.last.raw_content.should be_nil
140
+ end
141
+
142
+ it "should recognize a mixture of chapters with and without verses" do
143
+ chapters = ChapterReference.parse_chapters "1, 3:1-10; 5, 6:10,12,15, 8:10,11;15;16:1"
144
+ chapters.length.should eql 7
145
+
146
+ chapters[0].number.should eql 1
147
+ chapters[0].raw_content.should be_nil
148
+
149
+ chapters[1].number.should eql 3
150
+ chapters[1].raw_content.should eql "1-10"
151
+
152
+ chapters[2].number.should eql 5
153
+ chapters[2].raw_content.should be_nil
154
+
155
+ chapters[3].number.should eql 6
156
+ chapters[3].raw_content.should eql "10,12,15"
157
+
158
+ chapters[4].number.should eql 8
159
+ chapters[4].raw_content.should eql "10,11"
160
+
161
+ chapters[5].number.should eql 15
162
+ chapters[5].raw_content.should be_nil
163
+
164
+ chapters[6].number.should eql 16
165
+ chapters[6].raw_content.should eql "1"
166
+ end
167
+
168
+ it "should recognize passages beginning and ending with a single chapter" do
169
+ chapters = ChapterReference.parse_chapters "1, 5:10-12; 15"
170
+ chapters.length.should eql 3
171
+ chapters[0].number.should eql 1
172
+ chapters[1].number.should eql 5
173
+ chapters[1].raw_content.should eql "10-12"
174
+ chapters[2].number.should eql 15
175
+ end
176
+
177
+ it "should recognize passages beginning and ending with a chapter with verses" do
178
+ chapters = ChapterReference.parse_chapters "1:1;5;6:10"
179
+ chapters.length.should eql 3
180
+ chapters[0].number.should eql 1
181
+ chapters[0].raw_content.should eql "1"
182
+ chapters[1].number.should eql 5
183
+ chapters[1].raw_content.should be_nil
184
+ chapters[2].number.should eql 6
185
+ chapters[2].raw_content.should eql "10"
186
+ end
187
+
188
+ it "should recognize a simple range of chapters" do
189
+ chapters = ChapterReference.parse_chapters("1-5")
190
+ chapters.length.should eql 5
191
+ chapters[0].number.should eql 1
192
+ chapters[1].number.should eql 2
193
+ chapters[2].number.should eql 3
194
+ chapters[3].number.should eql 4
195
+ chapters[4].number.should eql 5
196
+ end
197
+
198
+ it "should recognize multiple digit ranges" do
199
+ chapters = ChapterReference.parse_chapters "90-110"
200
+ chapters.length.should eql 21
201
+ end
202
+
203
+ it "should recognize a complex range of chapters" do
204
+ chapters = ChapterReference.parse_chapters("1:10, 2:20-25; 4-7, 12:16; 15-17;; 19, 22, 25-28, 30")
205
+ chapters.length.should eql 17
206
+
207
+ chapters[0].number.should eql 1
208
+ chapters[0].raw_content.should eql "10"
209
+
210
+ chapters[1].number.should eql 2
211
+ chapters[1].raw_content.should eql "20-25"
212
+
213
+ chapters[2].number.should eql 4
214
+ chapters[2].raw_content.should be_nil
215
+
216
+ chapters[3].number.should eql 5
217
+ chapters[3].raw_content.should be_nil
218
+
219
+ chapters[4].number.should eql 6
220
+ chapters[4].raw_content.should be_nil
221
+
222
+ chapters[5].number.should eql 7
223
+ chapters[5].raw_content.should be_nil
224
+
225
+ chapters[6].number.should eql 12
226
+ chapters[6].raw_content.should eql "16"
227
+
228
+ chapters[7].number.should eql 15
229
+ chapters[7].raw_content.should be_nil
230
+
231
+ chapters[8].number.should eql 16
232
+ chapters[8].raw_content.should be_nil
233
+
234
+ chapters[9].number.should eql 17
235
+ chapters[9].raw_content.should be_nil
236
+
237
+ chapters[10].number.should eql 19
238
+ chapters[10].raw_content.should be_nil
239
+
240
+ chapters[11].number.should eql 22
241
+ chapters[11].raw_content.should be_nil
242
+
243
+ chapters[12].number.should eql 25
244
+ chapters[12].raw_content.should be_nil
245
+
246
+ chapters[13].number.should eql 26
247
+ chapters[13].raw_content.should be_nil
248
+
249
+ chapters[14].number.should eql 27
250
+ chapters[14].raw_content.should be_nil
251
+
252
+ chapters[15].number.should eql 28
253
+ chapters[15].raw_content.should be_nil
254
+
255
+ chapters[16].number.should eql 30
256
+ chapters[16].raw_content.should be_nil
257
+ end
258
+
259
+ it "should recognize two back-to-back double digit chapters with verses" do
260
+ chapters = ChapterReference.parse_chapters "15:1-5,15, 20:1-10,15"
261
+ chapters.length.should eql 2
262
+ chapters.first.number.should eql 15
263
+ chapters.first.raw_content.should eql "1-5,15"
264
+ chapters.last.number.should eql 20
265
+ chapters.last.raw_content.should eql "1-10,15"
266
+ end
267
+
268
+ it "should recognize chapters and raw_content in a complex string in the correct order" do
269
+ # chapters are 1, 2, 3, 4, 5, 6, 7, 8, 9, 25, 14, 19, 100,10000
270
+ string = "1, 2:10,12, 3:13, 4:1-10, 20\n;5, 6;7;8:10000;9;25:12;;;14:1-21,19:20-26,;,100,10000"
271
+ chapters = ChapterReference.parse_chapters string
272
+
273
+ chapters.length.should eql 14
274
+ chapters[0].number.should eql 1
275
+ chapters[0].raw_content.should be_nil
276
+
277
+ chapters[1].number.should eql 2
278
+ chapters[1].raw_content.should eql "10,12"
279
+
280
+ chapters[2].number.should eql 3
281
+ chapters[2].raw_content.should eql "13"
282
+
283
+ chapters[3].number.should eql 4
284
+ chapters[3].raw_content.should eql "1-10,20"
285
+
286
+ chapters[4].number.should eql 5
287
+ chapters[4].raw_content.should be_nil
288
+
289
+ chapters[5].number.should eql 6
290
+ chapters[5].raw_content.should be_nil
291
+
292
+ chapters[6].number.should eql 7
293
+ chapters[6].raw_content.should be_nil
294
+
295
+ chapters[7].number.should eql 8
296
+ chapters[7].raw_content.should eql "10000"
297
+
298
+ chapters[8].number.should eql 9
299
+ chapters[8].raw_content.should be_nil
300
+
301
+ chapters[9].number.should eql 25
302
+ chapters[9].raw_content.should eql "12"
303
+
304
+ chapters[10].number.should eql 14
305
+ chapters[10].raw_content.should eql "1-21"
306
+
307
+ chapters[11].number.should eql 19
308
+ chapters[11].raw_content.should eql "20-26"
309
+
310
+ chapters[12].number.should eql 100
311
+ chapters[12].raw_content.should be_nil
312
+
313
+ chapters[13].number.should eql 10000
314
+ chapters[13].raw_content.should be_nil
315
+
316
+ end
317
+
318
+ it "should recognize chapters and raw_content in a passage with book names" do
319
+ chapters = ChapterReference.parse_chapters("Gen. 1:10, Mark 2:2-10, James 3 Gal 1")
320
+
321
+ chapters[0].number.should eql 1
322
+ chapters[0].raw_content.should eql "10"
323
+
324
+ chapters[1].number.should eql 2
325
+ chapters[1].raw_content.should eql "2-10"
326
+
327
+ chapters[2].number.should eql 3
328
+ chapters[2].raw_content.should be_nil
329
+
330
+ chapters[3].number.should eql 1
331
+ chapters[3].raw_content.should be_nil
332
+ end
333
+
334
+ it "should convert an int passage to a string" do
335
+ chapters = ChapterReference.parse_chapters 10
336
+ chapters.first.number.should eql 10
337
+ end
338
+ end
339
+
340
+ describe "the parse_chapters_in_reference method" do
341
+ it "should parse the right raw_content" do
342
+ book = BookReference.new "Matthew", "1:1-10"
343
+ chapters = ChapterReference.parse_chapters_in_reference book
344
+ chapters.first.number.should eql 1
345
+ chapters.first.raw_content.should eql "1-10"
346
+ end
347
+
348
+ it "should use the right book metadata" do
349
+ book = BookReference.new "Genesis", "51:1"
350
+ chapters = ChapterReference.parse_chapters_in_reference book
351
+ chapters.first.errors.first.should eql "Chapter '51' does not exist for the book Genesis"
352
+ end
353
+
354
+ it "should assume chapter 1 for book references with nil raw_content" do
355
+ book = BookReference.new "Matthew"
356
+ chapters = ChapterReference.parse_chapters_in_reference book
357
+ chapters.length.should eql 1
358
+ chapters.first.number.should eql 1
359
+ end
360
+ end
361
+
362
+ describe "each returned chapter" do
363
+ it "should correctly set the number attribute" do
364
+ chapters = ChapterReference.parse_chapters "1:1"
365
+ chapters.first.number.should eql 1
366
+ end
367
+
368
+ it "should correctly set the raw_content attribute" do
369
+ chapters = ChapterReference.parse_chapters "1:1-5"
370
+ chapters.first.raw_content.should eql "1-5"
371
+ end
372
+
373
+ it "should set the raw_content attribute to nil for a range" do
374
+ chapters = ChapterReference.parse_chapters "1-10"
375
+ chapters.first.raw_content.should be_nil
376
+ end
377
+
378
+ it "should correctly set the metadata attribute" do
379
+ metadata = BibleMetadata["Matthew"]
380
+ chapters = ChapterReference.parse_chapters "1:1", metadata
381
+ chapters.first.metadata.should eql metadata
382
+ end
383
+ end
384
+
385
+ describe "the returned value" do
386
+ it "should be a reference collection" do
387
+ chapters = ChapterReference.parse_chapters("1:1-10, 12:15")
388
+ chapters.should be_kind_of ReferenceCollection
389
+ end
390
+
391
+ it "should only contain ChapterReference objects" do
392
+ chapters = ChapterReference.parse_chapters("1:1-10, 12:15")
393
+ chapters.each do |chapter|
394
+ chapter.should be_kind_of ChapterReference
395
+ end
396
+ end
397
+ end
398
+
399
+ end
400
+
401
+ describe "the 'clean' method" do
402
+ it "should call clean on it's verse references" do
403
+ chapter = ChapterReference.new 1, "23-26", BibleMetadata["Matthew"]
404
+ chapter.verse_references.length.should eql 4
405
+
406
+ chapter.clean
407
+ chapter.verse_references.length.should eql 3
408
+ chapter.verse_references.invalid_references.length.should eql 1
409
+ end
410
+ end
411
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe BibleReferenceParser do
4
+ specify "the 'parse' method should parse books" do
5
+ books = BibleReferenceParser.parse("Genesis 1:1, Matthew 1:1")
6
+ books.length.should eql 2
7
+ end
8
+
9
+ specify "the 'parse_books' method should parse books" do
10
+ books = BibleReferenceParser.parse_books("Genesis 1:1, Matthew 1:1")
11
+ books.length.should eql 2
12
+ end
13
+
14
+ specify "the 'parse_chapters' method should parse books" do
15
+ chapters = BibleReferenceParser.parse_chapters("1-3, 7:15")
16
+ chapters.length.should eql 4
17
+ end
18
+
19
+ specify "the 'parse_verses' method should parse books" do
20
+ verses = BibleReferenceParser.parse_verses("1-10, 20")
21
+ verses.length.should eql 11
22
+ end
23
+ end
@@ -0,0 +1,237 @@
1
+ require 'spec_helper'
2
+
3
+ include BibleReferenceParser
4
+
5
+ describe ReferenceCollection do
6
+ it_should_behave_like "it tracks errors", ReferenceCollection.new
7
+
8
+ it "should delegate some of the Array methods" do
9
+ ref = ReferenceCollection.new
10
+ ref.should respond_to *%w{[] each + - << length first last empty?}
11
+ end
12
+
13
+ describe "initialization" do
14
+ it "should set references to an empty array by default" do
15
+ ref = ReferenceCollection.new
16
+ ref.references.should eql []
17
+ end
18
+
19
+ it "should set invalid_references to an empty array by default" do
20
+ ref = ReferenceCollection.new
21
+ ref.invalid_references.should eql []
22
+ end
23
+
24
+ it "should set references to the parameter passed in" do
25
+ book = BookReference.new "Matthew"
26
+ initial = [book]
27
+ ref = ReferenceCollection.new(initial)
28
+ ref.references.should eql initial
29
+ end
30
+
31
+ it "should set the invalid_references to the parameter passed in" do
32
+ book = BookReference.new "Matthewz"
33
+ initial = [book]
34
+ ref = ReferenceCollection.new([], initial)
35
+ ref.invalid_references.should eql initial
36
+ end
37
+ end
38
+
39
+ describe "the '+' method" do
40
+ before :each do
41
+ @book1 = BookReference.new "Matthew"
42
+ @book2 = BookReference.new "Genesis"
43
+ @ref1 = ReferenceCollection.new [@book1]
44
+ end
45
+
46
+ shared_examples_for "it delegates the + method" do
47
+ it "should return a ReferenceCollection" do
48
+ @ref2.should be_kind_of ReferenceCollection
49
+ end
50
+
51
+ it "should contain the new references" do
52
+ @ref2.first.name.should eql @book1.name
53
+ end
54
+
55
+ it "should retain the existing references" do
56
+ @ref2.last.name.should eql @book2.name
57
+ end
58
+
59
+ it "should only contain the existing and new references" do
60
+ @ref2.length.should eql 2
61
+ end
62
+ end
63
+
64
+ context "when adding an Array" do
65
+ before :each do
66
+ @ref2 = @ref1 + [@book2]
67
+ end
68
+
69
+ it_should_behave_like "it delegates the + method"
70
+
71
+ it "should retain the existing invalid references" do
72
+ ref1 = ReferenceCollection.new [], [@book1]
73
+ ref2 = ref1 + [@book2]
74
+ ref2.invalid_references.length.should eql 1
75
+ ref2.invalid_references.first.name.should eql @book1.name
76
+ end
77
+ end
78
+
79
+ context "when adding a ReferenceCollection" do
80
+ before :each do
81
+ @ref2 = @ref1 + ReferenceCollection.new([@book2])
82
+ end
83
+
84
+ it_should_behave_like "it delegates the + method"
85
+
86
+ it "should retain the existing invalid references" do
87
+ ref1 = ReferenceCollection.new [], [@book1]
88
+ ref2 = ref1 + ReferenceCollection.new([@book2])
89
+ ref2.invalid_references.length.should eql 1
90
+ ref2.invalid_references.first.name.should eql @book1.name
91
+ end
92
+ end
93
+ end
94
+
95
+ describe "the '-' method" do
96
+ before :each do
97
+ @book1 = BookReference.new "Matthew"
98
+ @book2 = BookReference.new "Genesis"
99
+ @ref1 = ReferenceCollection.new [@book1, @book2]
100
+ end
101
+
102
+ context "when adding an Array" do
103
+ before :each do
104
+ @ref2 = @ref1 - [@book2]
105
+ end
106
+
107
+ it "should return a ReferenceCollection" do
108
+ @ref2.should be_kind_of ReferenceCollection
109
+ end
110
+
111
+ it "should only contain the references not subtracted" do
112
+ @ref2.length.should eql 1
113
+ @ref2.first.name.should eql @book1.name
114
+ end
115
+
116
+ it "should retain the existing invalid references" do
117
+ ref1 = ReferenceCollection.new [], [@book1]
118
+ ref2 = ref1 - [@book2]
119
+ ref2.invalid_references.length.should eql 1
120
+ ref2.invalid_references.first.name.should eql @book1.name
121
+ end
122
+ end
123
+
124
+ context "when adding a ReferenceCollection" do
125
+ before :each do
126
+ @ref2 = @ref1 - ReferenceCollection.new([@book2])
127
+ end
128
+
129
+ it "should return a ReferenceCollection" do
130
+ @ref2.should be_kind_of ReferenceCollection
131
+ end
132
+
133
+ it "should only contain the references not subtracted" do
134
+ @ref2.length.should eql 1
135
+ @ref2.first.name.should eql @book1.name
136
+ end
137
+
138
+ it "should retain the existing invalid references" do
139
+ ref1 = ReferenceCollection.new [], [@book1]
140
+ ref2 = ref1 - [@book2]
141
+ ref2.invalid_references.length.should eql 1
142
+ ref2.invalid_references.first.name.should eql @book1.name
143
+ end
144
+ end
145
+ end
146
+
147
+ describe "the errors method" do
148
+ it "should include errors for any of the items it contains" do
149
+ ref = ReferenceCollection.new
150
+ book = BookReference.new "Genthesis"
151
+
152
+ ref.errors.should be_empty
153
+ ref << book
154
+ ref.errors.first.should eql "The book 'Genthesis' could not be found"
155
+ end
156
+
157
+ it "should include errors for invalid references" do
158
+ book = BookReference.new "Genthesis"
159
+ ref = ReferenceCollection.new
160
+ ref << book
161
+ ref.clean
162
+ ref.errors.first.should eql "The book 'Genthesis' could not be found"
163
+ end
164
+
165
+ it "should not return contain duplicate errors" do
166
+ books = BookReference.parse_books "Genesis 51"
167
+ books.clean
168
+ books.errors.length.should eql 1
169
+ end
170
+ end
171
+
172
+ describe "the 'clean' method" do
173
+
174
+ describe "with the 'chain' parameter false" do
175
+ it "should remove bad references and leave good references" do
176
+ books = BookReference.parse_books("Genesis 1:1, Exoduth 1:1")
177
+ books.length.should eql 2
178
+
179
+ books.clean(false)
180
+ books.length.should eql 1
181
+ books.first.name.should eql "Genesis"
182
+ books.invalid_references.length.should eql 1
183
+ end
184
+
185
+ it "should not remove any bad child references" do
186
+ books = BookReference.parse_books("Genesis 51:1, Exodus 1:100")
187
+ books.length.should eql 2
188
+
189
+ books.clean(false)
190
+ books.first.chapter_references.length.should eql 1
191
+ books.first.chapter_references.invalid_references.length.should eql 0
192
+ books.last.chapter_references.first.verse_references.length.should eql 1
193
+ books.last.chapter_references.first.verse_references.invalid_references.length.should eql 0
194
+ end
195
+
196
+ it "should return the references that were removed" do
197
+ books = BookReference.parse_books("Genesis 1:1, Exoduth 1:1, Numbers 100")
198
+ cleaned = books.clean(false)
199
+
200
+ cleaned.length.should eql 1
201
+ cleaned.first.errors.first.should eql "The book 'Exoduth' could not be found"
202
+ end
203
+ end
204
+
205
+ describe "with the 'chain' parameter true" do
206
+ it "should remove bad references and leave good references" do
207
+ books = BookReference.parse_books("Genesis 1:1, Exoduth 1:1")
208
+ books.length.should eql 2
209
+
210
+ books.clean
211
+ books.length.should eql 1
212
+ books.first.name.should eql "Genesis"
213
+ books.invalid_references.length.should eql 1
214
+ end
215
+
216
+ it "should remove any bad child references" do
217
+ books = BookReference.parse_books("Genesis 51:1, Exodus 1:100")
218
+ books.length.should eql 2
219
+
220
+ books.clean
221
+ books.first.chapter_references.length.should eql 0
222
+ books.first.chapter_references.invalid_references.length.should eql 1
223
+ books.last.chapter_references.first.verse_references.length.should eql 0
224
+ books.last.chapter_references.first.verse_references.invalid_references.length.should eql 1
225
+ end
226
+
227
+ it "should return the references that were removed" do
228
+ books = BookReference.parse_books("Genesis 1:1, Exoduth 1:1, Numbers 100")
229
+ cleaned = books.clean
230
+
231
+ cleaned.length.should eql 2
232
+ cleaned.first.errors.first.should eql "The book 'Exoduth' could not be found"
233
+ cleaned.last.errors.first.should eql "Chapter '100' does not exist for the book Numbers"
234
+ end
235
+ end
236
+ end
237
+ end