ruby-marc-spec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +18 -0
- data/.gitignore +388 -0
- data/.gitmodules +3 -0
- data/.idea/codeStyles/codeStyleConfig.xml +5 -0
- data/.idea/go.imports.xml +6 -0
- data/.idea/inspectionProfiles/Project_Default.xml +23 -0
- data/.idea/marc_spec.iml +102 -0
- data/.idea/misc.xml +6 -0
- data/.idea/modules.xml +8 -0
- data/.idea/templateLanguages.xml +6 -0
- data/.idea/vcs.xml +7 -0
- data/.rubocop.yml +269 -0
- data/.ruby-version +1 -0
- data/.simplecov +8 -0
- data/CHANGES.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE.md +21 -0
- data/README.md +172 -0
- data/Rakefile +20 -0
- data/lib/.rubocop.yml +5 -0
- data/lib/marc/spec/module_info.rb +14 -0
- data/lib/marc/spec/parsing/closed_int_range.rb +28 -0
- data/lib/marc/spec/parsing/closed_lc_alpha_range.rb +28 -0
- data/lib/marc/spec/parsing/parser.rb +213 -0
- data/lib/marc/spec/parsing.rb +1 -0
- data/lib/marc/spec/queries/al_num_range.rb +105 -0
- data/lib/marc/spec/queries/applicable.rb +18 -0
- data/lib/marc/spec/queries/character_spec.rb +81 -0
- data/lib/marc/spec/queries/comparison_string.rb +45 -0
- data/lib/marc/spec/queries/condition.rb +133 -0
- data/lib/marc/spec/queries/condition_context.rb +49 -0
- data/lib/marc/spec/queries/dsl.rb +80 -0
- data/lib/marc/spec/queries/indicator_value.rb +77 -0
- data/lib/marc/spec/queries/operator.rb +129 -0
- data/lib/marc/spec/queries/part.rb +63 -0
- data/lib/marc/spec/queries/position.rb +59 -0
- data/lib/marc/spec/queries/position_or_range.rb +27 -0
- data/lib/marc/spec/queries/query.rb +94 -0
- data/lib/marc/spec/queries/query_executor.rb +52 -0
- data/lib/marc/spec/queries/selector.rb +12 -0
- data/lib/marc/spec/queries/subfield.rb +88 -0
- data/lib/marc/spec/queries/subfield_value.rb +63 -0
- data/lib/marc/spec/queries/tag.rb +107 -0
- data/lib/marc/spec/queries/transform.rb +154 -0
- data/lib/marc/spec/queries.rb +1 -0
- data/lib/marc/spec.rb +32 -0
- data/rakelib/.rubocop.yml +19 -0
- data/rakelib/bundle.rake +8 -0
- data/rakelib/coverage.rake +11 -0
- data/rakelib/gem.rake +54 -0
- data/rakelib/parser_specs/formatter.rb +31 -0
- data/rakelib/parser_specs/parser_specs.rb.txt.erb +35 -0
- data/rakelib/parser_specs/rule.rb +95 -0
- data/rakelib/parser_specs/suite.rb +91 -0
- data/rakelib/parser_specs/test.rb +97 -0
- data/rakelib/parser_specs.rb +1 -0
- data/rakelib/rubocop.rake +18 -0
- data/rakelib/spec.rake +27 -0
- data/ruby-marc-spec.gemspec +42 -0
- data/spec/.rubocop.yml +46 -0
- data/spec/README.md +16 -0
- data/spec/data/b23161018-sru.xml +182 -0
- data/spec/data/sandburg.xml +82 -0
- data/spec/generated/char_indicator_spec.rb +174 -0
- data/spec/generated/char_spec.rb +113 -0
- data/spec/generated/comparison_string_spec.rb +74 -0
- data/spec/generated/field_tag_spec.rb +156 -0
- data/spec/generated/index_char_spec.rb +669 -0
- data/spec/generated/index_indicator_spec.rb +174 -0
- data/spec/generated/index_spec.rb +113 -0
- data/spec/generated/index_sub_spec_spec.rb +1087 -0
- data/spec/generated/indicators_spec.rb +75 -0
- data/spec/generated/position_or_range_spec.rb +110 -0
- data/spec/generated/sub_spec_spec.rb +208 -0
- data/spec/generated/sub_spec_sub_spec_spec.rb +1829 -0
- data/spec/generated/subfield_char_spec.rb +405 -0
- data/spec/generated/subfield_range_range_spec.rb +48 -0
- data/spec/generated/subfield_range_spec.rb +87 -0
- data/spec/generated/subfield_range_sub_spec_spec.rb +214 -0
- data/spec/generated/subfield_tag_range_spec.rb +477 -0
- data/spec/generated/subfield_tag_sub_spec_spec.rb +3216 -0
- data/spec/generated/subfield_tag_tag_spec.rb +5592 -0
- data/spec/marc/spec/parsing/closed_int_range_spec.rb +49 -0
- data/spec/marc/spec/parsing/closed_lc_alpha_range_spec.rb +49 -0
- data/spec/marc/spec/parsing/parser_spec.rb +545 -0
- data/spec/marc/spec/queries/al_num_range_spec.rb +114 -0
- data/spec/marc/spec/queries/character_spec_spec.rb +28 -0
- data/spec/marc/spec/queries/comparison_string_spec.rb +28 -0
- data/spec/marc/spec/queries/indicator_value_spec.rb +28 -0
- data/spec/marc/spec/queries/query_spec.rb +200 -0
- data/spec/marc/spec/queries/subfield_spec.rb +92 -0
- data/spec/marc/spec/queries/subfield_value_spec.rb +31 -0
- data/spec/marc/spec/queries/tag_spec.rb +144 -0
- data/spec/marc/spec/queries/transform_spec.rb +459 -0
- data/spec/marc_spec_spec.rb +247 -0
- data/spec/scratch_spec.rb +112 -0
- data/spec/spec_helper.rb +23 -0
- metadata +341 -0
@@ -0,0 +1,405 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'parslet/rig/rspec'
|
3
|
+
|
4
|
+
module MARC
|
5
|
+
module Spec
|
6
|
+
module Parsing
|
7
|
+
context 'suite' do
|
8
|
+
describe :subfield_char do
|
9
|
+
let(:parser) { Parser.new }
|
10
|
+
let(:reporter) { Parslet::ErrorReporter::Deepest.new }
|
11
|
+
|
12
|
+
describe 'marc_spec: valid field tag and invalid subfield tag' do
|
13
|
+
# /invalid/wildCombination_invalidSubfieldTag.json
|
14
|
+
it "char '|' is not allowed -> invalid" do
|
15
|
+
# /invalid/wildCombination_invalidSubfieldTag.json
|
16
|
+
expect(parser.marc_spec).not_to parse('...$|', trace: true, reporter: reporter)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "char 'ß' is not allowed -> invalid" do
|
20
|
+
# /invalid/wildCombination_invalidSubfieldTag.json
|
21
|
+
expect(parser.marc_spec).not_to parse('...$ß', trace: true, reporter: reporter)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'only one digit allowed -> invalid' do
|
25
|
+
# /invalid/wildCombination_invalidSubfieldTag.json
|
26
|
+
expect(parser.marc_spec).not_to parse('...$10', trace: true, reporter: reporter)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'uppercase chars are not allowed -> invalid' do
|
30
|
+
# /invalid/wildCombination_invalidSubfieldTag.json
|
31
|
+
expect(parser.marc_spec).not_to parse('...$A', trace: true, reporter: reporter)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'whitespace is not allowed -> invalid' do
|
35
|
+
# /invalid/wildCombination_invalidSubfieldTag.json
|
36
|
+
expect(parser.marc_spec).not_to parse('...$ a', trace: true, reporter: reporter)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
describe 'marc_spec: valid field tag and subfield tag' do
|
41
|
+
# /valid/wildCombination_validSubfieldTag.json
|
42
|
+
it 'digit subfieldtag 0 -> valid' do
|
43
|
+
# /valid/wildCombination_validSubfieldTag.json
|
44
|
+
expect(parser.marc_spec).to parse('...$0', trace: true, reporter: reporter)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'digit subfieldtag 9 -> valid' do
|
48
|
+
# /valid/wildCombination_validSubfieldTag.json
|
49
|
+
expect(parser.marc_spec).to parse('...$9', trace: true, reporter: reporter)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'lowercase alpha subfieldtag a -> valid' do
|
53
|
+
# /valid/wildCombination_validSubfieldTag.json
|
54
|
+
expect(parser.marc_spec).to parse('...$a', trace: true, reporter: reporter)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'lowercase alpha subfieldtag z -> valid' do
|
58
|
+
# /valid/wildCombination_validSubfieldTag.json
|
59
|
+
expect(parser.marc_spec).to parse('...$z', trace: true, reporter: reporter)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'subfieldtag ! -> valid' do
|
63
|
+
# /valid/wildCombination_validSubfieldTag.json
|
64
|
+
expect(parser.marc_spec).to parse('...$!', trace: true, reporter: reporter)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'subfieldtag # -> valid' do
|
68
|
+
# /valid/wildCombination_validSubfieldTag.json
|
69
|
+
expect(parser.marc_spec).to parse('...$#', trace: true, reporter: reporter)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'subfieldtag $ -> valid' do
|
73
|
+
# /valid/wildCombination_validSubfieldTag.json
|
74
|
+
expect(parser.marc_spec).to parse('...$$', trace: true, reporter: reporter)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'subfieldtag % -> valid' do
|
78
|
+
# /valid/wildCombination_validSubfieldTag.json
|
79
|
+
expect(parser.marc_spec).to parse('...$%', trace: true, reporter: reporter)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'subfieldtag & -> valid' do
|
83
|
+
# /valid/wildCombination_validSubfieldTag.json
|
84
|
+
expect(parser.marc_spec).to parse('...$&', trace: true, reporter: reporter)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "subfieldtag ' -> valid" do
|
88
|
+
# /valid/wildCombination_validSubfieldTag.json
|
89
|
+
expect(parser.marc_spec).to parse("...$'", trace: true, reporter: reporter)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'subfieldtag ( -> valid' do
|
93
|
+
# /valid/wildCombination_validSubfieldTag.json
|
94
|
+
expect(parser.marc_spec).to parse('...$(', trace: true, reporter: reporter)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'subfieldtag ) -> valid' do
|
98
|
+
# /valid/wildCombination_validSubfieldTag.json
|
99
|
+
expect(parser.marc_spec).to parse('...$)', trace: true, reporter: reporter)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'subfieldtag * -> valid' do
|
103
|
+
# /valid/wildCombination_validSubfieldTag.json
|
104
|
+
expect(parser.marc_spec).to parse('...$*', trace: true, reporter: reporter)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'subfieldtag + -> valid' do
|
108
|
+
# /valid/wildCombination_validSubfieldTag.json
|
109
|
+
expect(parser.marc_spec).to parse('...$+', trace: true, reporter: reporter)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'subfieldtag , -> valid' do
|
113
|
+
# /valid/wildCombination_validSubfieldTag.json
|
114
|
+
expect(parser.marc_spec).to parse('...$,', trace: true, reporter: reporter)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'subfieldtag - -> valid' do
|
118
|
+
# /valid/wildCombination_validSubfieldTag.json
|
119
|
+
expect(parser.marc_spec).to parse('...$-', trace: true, reporter: reporter)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'subfieldtag . -> valid' do
|
123
|
+
# /valid/wildCombination_validSubfieldTag.json
|
124
|
+
expect(parser.marc_spec).to parse('...$.', trace: true, reporter: reporter)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'subfieldtag / -> valid' do
|
128
|
+
# /valid/wildCombination_validSubfieldTag.json
|
129
|
+
expect(parser.marc_spec).to parse('...$/', trace: true, reporter: reporter)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'subfieldtag : -> valid' do
|
133
|
+
# /valid/wildCombination_validSubfieldTag.json
|
134
|
+
expect(parser.marc_spec).to parse('...$:', trace: true, reporter: reporter)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'subfieldtag ; -> valid' do
|
138
|
+
# /valid/wildCombination_validSubfieldTag.json
|
139
|
+
expect(parser.marc_spec).to parse('...$;', trace: true, reporter: reporter)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'subfieldtag < -> valid' do
|
143
|
+
# /valid/wildCombination_validSubfieldTag.json
|
144
|
+
expect(parser.marc_spec).to parse('...$<', trace: true, reporter: reporter)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'subfieldtag = -> valid' do
|
148
|
+
# /valid/wildCombination_validSubfieldTag.json
|
149
|
+
expect(parser.marc_spec).to parse('...$=', trace: true, reporter: reporter)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'subfieldtag > -> valid' do
|
153
|
+
# /valid/wildCombination_validSubfieldTag.json
|
154
|
+
expect(parser.marc_spec).to parse('...$>', trace: true, reporter: reporter)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'subfieldtag ? -> valid' do
|
158
|
+
# /valid/wildCombination_validSubfieldTag.json
|
159
|
+
expect(parser.marc_spec).to parse('...$?', trace: true, reporter: reporter)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'subfieldtag [ -> valid' do
|
163
|
+
# /valid/wildCombination_validSubfieldTag.json
|
164
|
+
expect(parser.marc_spec).to parse('...$[', trace: true, reporter: reporter)
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'subfieldtag \\ -> valid' do
|
168
|
+
# /valid/wildCombination_validSubfieldTag.json
|
169
|
+
expect(parser.marc_spec).to parse('...$\\', trace: true, reporter: reporter)
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'subfieldtag ] -> valid' do
|
173
|
+
# /valid/wildCombination_validSubfieldTag.json
|
174
|
+
expect(parser.marc_spec).to parse('...$]', trace: true, reporter: reporter)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'subfieldtag ^ -> valid' do
|
178
|
+
# /valid/wildCombination_validSubfieldTag.json
|
179
|
+
expect(parser.marc_spec).to parse('...$^', trace: true, reporter: reporter)
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'subfieldtag _ -> valid' do
|
183
|
+
# /valid/wildCombination_validSubfieldTag.json
|
184
|
+
expect(parser.marc_spec).to parse('...$_', trace: true, reporter: reporter)
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'subfieldtag ` -> valid' do
|
188
|
+
# /valid/wildCombination_validSubfieldTag.json
|
189
|
+
expect(parser.marc_spec).to parse('...$`', trace: true, reporter: reporter)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'subfieldtag { -> valid' do
|
193
|
+
# /valid/wildCombination_validSubfieldTag.json
|
194
|
+
expect(parser.marc_spec).to parse('...${', trace: true, reporter: reporter)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'subfieldtag } -> valid' do
|
198
|
+
# /valid/wildCombination_validSubfieldTag.json
|
199
|
+
expect(parser.marc_spec).to parse('...$}', trace: true, reporter: reporter)
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'subfieldtag ~ -> valid' do
|
203
|
+
# /valid/wildCombination_validSubfieldTag.json
|
204
|
+
expect(parser.marc_spec).to parse('...$~', trace: true, reporter: reporter)
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
describe 'subfield tags are strings and match pattern' do
|
209
|
+
# /invalid/invalidSubfieldTag.json
|
210
|
+
it "char '|' is not allowed -> invalid" do
|
211
|
+
# /invalid/invalidSubfieldTag.json
|
212
|
+
expect(parser.subfield_char).not_to parse('|', trace: true, reporter: reporter)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "char 'ß' is not allowed -> invalid" do
|
216
|
+
# /invalid/invalidSubfieldTag.json
|
217
|
+
expect(parser.subfield_char).not_to parse('ß', trace: true, reporter: reporter)
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'digit subfieldtag 0 -> valid' do
|
221
|
+
# /valid/validSubfieldTag.json
|
222
|
+
expect(parser.subfield_char).to parse('0', trace: true, reporter: reporter)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'digit subfieldtag 9 -> valid' do
|
226
|
+
# /valid/validSubfieldTag.json
|
227
|
+
expect(parser.subfield_char).to parse('9', trace: true, reporter: reporter)
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'lowercase alpha subfieldtag a -> valid' do
|
231
|
+
# /valid/validSubfieldTag.json
|
232
|
+
expect(parser.subfield_char).to parse('a', trace: true, reporter: reporter)
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'lowercase alpha subfieldtag z -> valid' do
|
236
|
+
# /valid/validSubfieldTag.json
|
237
|
+
expect(parser.subfield_char).to parse('z', trace: true, reporter: reporter)
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'only one digit allowed -> invalid' do
|
241
|
+
# /invalid/invalidSubfieldTag.json
|
242
|
+
expect(parser.subfield_char).not_to parse('10', trace: true, reporter: reporter)
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'subfieldtag ! -> valid' do
|
246
|
+
# /valid/validSubfieldTag.json
|
247
|
+
expect(parser.subfield_char).to parse('!', trace: true, reporter: reporter)
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'subfieldtag # -> valid' do
|
251
|
+
# /valid/validSubfieldTag.json
|
252
|
+
expect(parser.subfield_char).to parse('#', trace: true, reporter: reporter)
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'subfieldtag $ -> valid' do
|
256
|
+
# /valid/validSubfieldTag.json
|
257
|
+
expect(parser.subfield_char).to parse('$', trace: true, reporter: reporter)
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'subfieldtag % -> valid' do
|
261
|
+
# /valid/validSubfieldTag.json
|
262
|
+
expect(parser.subfield_char).to parse('%', trace: true, reporter: reporter)
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'subfieldtag & -> valid' do
|
266
|
+
# /valid/validSubfieldTag.json
|
267
|
+
expect(parser.subfield_char).to parse('&', trace: true, reporter: reporter)
|
268
|
+
end
|
269
|
+
|
270
|
+
it "subfieldtag ' -> valid" do
|
271
|
+
# /valid/validSubfieldTag.json
|
272
|
+
expect(parser.subfield_char).to parse("'", trace: true, reporter: reporter)
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'subfieldtag ( -> valid' do
|
276
|
+
# /valid/validSubfieldTag.json
|
277
|
+
expect(parser.subfield_char).to parse('(', trace: true, reporter: reporter)
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'subfieldtag ) -> valid' do
|
281
|
+
# /valid/validSubfieldTag.json
|
282
|
+
expect(parser.subfield_char).to parse(')', trace: true, reporter: reporter)
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'subfieldtag * -> valid' do
|
286
|
+
# /valid/validSubfieldTag.json
|
287
|
+
expect(parser.subfield_char).to parse('*', trace: true, reporter: reporter)
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'subfieldtag + -> valid' do
|
291
|
+
# /valid/validSubfieldTag.json
|
292
|
+
expect(parser.subfield_char).to parse('+', trace: true, reporter: reporter)
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'subfieldtag , -> valid' do
|
296
|
+
# /valid/validSubfieldTag.json
|
297
|
+
expect(parser.subfield_char).to parse(',', trace: true, reporter: reporter)
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'subfieldtag - -> valid' do
|
301
|
+
# /valid/validSubfieldTag.json
|
302
|
+
expect(parser.subfield_char).to parse('-', trace: true, reporter: reporter)
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'subfieldtag . -> valid' do
|
306
|
+
# /valid/validSubfieldTag.json
|
307
|
+
expect(parser.subfield_char).to parse('.', trace: true, reporter: reporter)
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'subfieldtag / -> valid' do
|
311
|
+
# /valid/validSubfieldTag.json
|
312
|
+
expect(parser.subfield_char).to parse('/', trace: true, reporter: reporter)
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'subfieldtag : -> valid' do
|
316
|
+
# /valid/validSubfieldTag.json
|
317
|
+
expect(parser.subfield_char).to parse(':', trace: true, reporter: reporter)
|
318
|
+
end
|
319
|
+
|
320
|
+
it 'subfieldtag ; -> valid' do
|
321
|
+
# /valid/validSubfieldTag.json
|
322
|
+
expect(parser.subfield_char).to parse(';', trace: true, reporter: reporter)
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'subfieldtag < -> valid' do
|
326
|
+
# /valid/validSubfieldTag.json
|
327
|
+
expect(parser.subfield_char).to parse('<', trace: true, reporter: reporter)
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'subfieldtag = -> valid' do
|
331
|
+
# /valid/validSubfieldTag.json
|
332
|
+
expect(parser.subfield_char).to parse('=', trace: true, reporter: reporter)
|
333
|
+
end
|
334
|
+
|
335
|
+
it 'subfieldtag > -> valid' do
|
336
|
+
# /valid/validSubfieldTag.json
|
337
|
+
expect(parser.subfield_char).to parse('>', trace: true, reporter: reporter)
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'subfieldtag ? -> valid' do
|
341
|
+
# /valid/validSubfieldTag.json
|
342
|
+
expect(parser.subfield_char).to parse('?', trace: true, reporter: reporter)
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'subfieldtag [ -> valid' do
|
346
|
+
# /valid/validSubfieldTag.json
|
347
|
+
expect(parser.subfield_char).to parse('[', trace: true, reporter: reporter)
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'subfieldtag \\ -> valid' do
|
351
|
+
# /valid/validSubfieldTag.json
|
352
|
+
expect(parser.subfield_char).to parse('\\', trace: true, reporter: reporter)
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'subfieldtag ] -> valid' do
|
356
|
+
# /valid/validSubfieldTag.json
|
357
|
+
expect(parser.subfield_char).to parse(']', trace: true, reporter: reporter)
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'subfieldtag ^ -> valid' do
|
361
|
+
# /valid/validSubfieldTag.json
|
362
|
+
expect(parser.subfield_char).to parse('^', trace: true, reporter: reporter)
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'subfieldtag _ -> valid' do
|
366
|
+
# /valid/validSubfieldTag.json
|
367
|
+
expect(parser.subfield_char).to parse('_', trace: true, reporter: reporter)
|
368
|
+
end
|
369
|
+
|
370
|
+
it 'subfieldtag ` -> valid' do
|
371
|
+
# /valid/validSubfieldTag.json
|
372
|
+
expect(parser.subfield_char).to parse('`', trace: true, reporter: reporter)
|
373
|
+
end
|
374
|
+
|
375
|
+
it 'subfieldtag { -> valid' do
|
376
|
+
# /valid/validSubfieldTag.json
|
377
|
+
expect(parser.subfield_char).to parse('{', trace: true, reporter: reporter)
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'subfieldtag } -> valid' do
|
381
|
+
# /valid/validSubfieldTag.json
|
382
|
+
expect(parser.subfield_char).to parse('}', trace: true, reporter: reporter)
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'subfieldtag ~ -> valid' do
|
386
|
+
# /valid/validSubfieldTag.json
|
387
|
+
expect(parser.subfield_char).to parse('~', trace: true, reporter: reporter)
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'uppercase chars are not allowed -> invalid' do
|
391
|
+
# /invalid/invalidSubfieldTag.json
|
392
|
+
expect(parser.subfield_char).not_to parse('A', trace: true, reporter: reporter)
|
393
|
+
end
|
394
|
+
|
395
|
+
it 'whitespace is not allowed -> invalid' do
|
396
|
+
# /invalid/invalidSubfieldTag.json
|
397
|
+
expect(parser.subfield_char).not_to parse(' a', trace: true, reporter: reporter)
|
398
|
+
end
|
399
|
+
|
400
|
+
end
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'parslet/rig/rspec'
|
3
|
+
|
4
|
+
module MARC
|
5
|
+
module Spec
|
6
|
+
module Parsing
|
7
|
+
context 'suite' do
|
8
|
+
describe :subfield_range_range do
|
9
|
+
let(:parser) { Parser.new }
|
10
|
+
let(:reporter) { Parslet::ErrorReporter::Deepest.new }
|
11
|
+
|
12
|
+
describe 'marc_spec: valid field tag and subfield ranges' do
|
13
|
+
# /valid/wildCombination_validSubfieldRangeRange.json
|
14
|
+
|
15
|
+
describe 'subfield range with lowercase subfieldtags' do
|
16
|
+
|
17
|
+
it '&& subfield range with digits -> valid' do
|
18
|
+
# /valid/wildCombination_validSubfieldRangeRange.json
|
19
|
+
expect(parser.marc_spec).to parse('...$a-z$0-9', trace: true, reporter: reporter)
|
20
|
+
end
|
21
|
+
|
22
|
+
it '&& subfield range with lowercase subfieldtags -> valid' do
|
23
|
+
# /valid/wildCombination_validSubfieldRangeRange.json
|
24
|
+
expect(parser.marc_spec).to parse('...$a-z$a-z', trace: true, reporter: reporter)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'subfield range with digits' do
|
30
|
+
|
31
|
+
it '&& subfield range with digits -> valid' do
|
32
|
+
# /valid/wildCombination_validSubfieldRangeRange.json
|
33
|
+
expect(parser.marc_spec).to parse('...$0-9$0-9', trace: true, reporter: reporter)
|
34
|
+
end
|
35
|
+
|
36
|
+
it '&& subfield range with lowercase subfieldtags -> valid' do
|
37
|
+
# /valid/wildCombination_validSubfieldRangeRange.json
|
38
|
+
expect(parser.marc_spec).to parse('...$0-9$a-z', trace: true, reporter: reporter)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'parslet/rig/rspec'
|
3
|
+
|
4
|
+
module MARC
|
5
|
+
module Spec
|
6
|
+
module Parsing
|
7
|
+
context 'suite' do
|
8
|
+
describe :subfield_range do
|
9
|
+
let(:parser) { Parser.new }
|
10
|
+
let(:reporter) { Parslet::ErrorReporter::Deepest.new }
|
11
|
+
|
12
|
+
describe 'marc_spec: valid field tag and invalid subfield range' do
|
13
|
+
# /invalid/wildCombination_invalidSubfieldRange.json
|
14
|
+
it 'matches the pattern but not a valid subfield tag range -> invalid' do
|
15
|
+
# /invalid/wildCombination_invalidSubfieldRange.json
|
16
|
+
expect(parser.marc_spec).not_to parse('...$1-0', trace: true, reporter: reporter)
|
17
|
+
expect(parser.marc_spec).not_to parse('...$z-a', trace: true, reporter: reporter)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'mix of alpha and digit -> invalid' do
|
21
|
+
# /invalid/wildCombination_invalidSubfieldRange.json
|
22
|
+
expect(parser.marc_spec).not_to parse('...$a-9', trace: true, reporter: reporter)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'mix of digit and alpha -> invalid' do
|
26
|
+
# /invalid/wildCombination_invalidSubfieldRange.json
|
27
|
+
expect(parser.marc_spec).not_to parse('...$0-a', trace: true, reporter: reporter)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'uppercase chars are not allowed -> invalid' do
|
31
|
+
# /invalid/wildCombination_invalidSubfieldRange.json
|
32
|
+
expect(parser.marc_spec).not_to parse('...$A-Z', trace: true, reporter: reporter)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
describe 'marc_spec: valid field tag and subfield range' do
|
37
|
+
# /valid/wildCombination_validSubfieldRange.json
|
38
|
+
it 'subfield range with digits -> valid' do
|
39
|
+
# /valid/wildCombination_validSubfieldRange.json
|
40
|
+
expect(parser.marc_spec).to parse('...$0-9', trace: true, reporter: reporter)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'subfield range with lowercase subfieldtags -> valid' do
|
44
|
+
# /valid/wildCombination_validSubfieldRange.json
|
45
|
+
expect(parser.marc_spec).to parse('...$a-z', trace: true, reporter: reporter)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
describe 'subfield ranges are strings and match pattern' do
|
50
|
+
# /invalid/invalidSubfieldRange.json
|
51
|
+
it 'matches the pattern but not a valid subfield tag range -> invalid' do
|
52
|
+
# /invalid/invalidSubfieldRange.json
|
53
|
+
expect(parser.subfield_range).not_to parse('1-0', trace: true, reporter: reporter)
|
54
|
+
expect(parser.subfield_range).not_to parse('z-a', trace: true, reporter: reporter)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'mix of alpha and digit -> invalid' do
|
58
|
+
# /invalid/invalidSubfieldRange.json
|
59
|
+
expect(parser.subfield_range).not_to parse('a-9', trace: true, reporter: reporter)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'mix of digit and alpha -> invalid' do
|
63
|
+
# /invalid/invalidSubfieldRange.json
|
64
|
+
expect(parser.subfield_range).not_to parse('0-a', trace: true, reporter: reporter)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'subfield range with digits -> valid' do
|
68
|
+
# /valid/validSubfieldRange.json
|
69
|
+
expect(parser.subfield_range).to parse('0-9', trace: true, reporter: reporter)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'subfield range with lowercase subfieldtags -> valid' do
|
73
|
+
# /valid/validSubfieldRange.json
|
74
|
+
expect(parser.subfield_range).to parse('a-z', trace: true, reporter: reporter)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'uppercase chars are not allowed -> invalid' do
|
78
|
+
# /invalid/invalidSubfieldRange.json
|
79
|
+
expect(parser.subfield_range).not_to parse('A-Z', trace: true, reporter: reporter)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|