relaton 1.7.pre7 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +34 -0
- data/.github/workflows/ubuntu.yml +32 -0
- data/.github/workflows/windows.yml +35 -0
- data/docs/README.adoc +3 -233
- data/lib/relaton/config.rb +2 -3
- data/lib/relaton/db.rb +35 -247
- data/lib/relaton/db_cache.rb +6 -28
- data/lib/relaton/processor.rb +0 -11
- data/lib/relaton/registry.rb +1 -1
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton.rb +7 -8
- data/relaton.gemspec +6 -8
- data/spec/relaton/db_cache_spec.rb +1 -1
- data/spec/relaton/db_spec.rb +0 -145
- data/spec/relaton/processor_spec.rb +0 -4
- data/spec/relaton/regirtry_spec.rb +44 -54
- data/spec/relaton_spec.rb +19 -120
- data/spec/vcr_cassetes/19133_2005.yml +20 -20
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +10 -10
- data/spec/vcr_cassetes/fisp_140.yml +6 -6
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +11 -15
- data/spec/vcr_cassetes/ieee_528_2019.yml +17 -17
- data/spec/vcr_cassetes/iho_b_11.yml +15 -15
- data/spec/vcr_cassetes/iso_111111119115_1.yml +5 -5
- data/spec/vcr_cassetes/iso_19115.yml +22 -22
- data/spec/vcr_cassetes/iso_19115_1.yml +20 -20
- data/spec/vcr_cassetes/iso_19115_1_2.yml +39 -39
- data/spec/vcr_cassetes/iso_awi_24229.yml +22 -22
- data/spec/vcr_cassetes/ogc_19_025r1.yml +1902 -2554
- data/spec/vcr_cassetes/ogm_ami4ccm_1_0.yml +7 -7
- data/spec/vcr_cassetes/rfc_8341.yml +15 -47
- data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
- data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -30
- data/spec/vcr_cassetes/w3c_json_ld11.yml +12 -12
- metadata +51 -61
- data/.github/workflows/rake.yml +0 -46
- data/globalcache/iec/iec_60050_102_2007.xml +0 -58
- data/globalcache/iec/version +0 -1
- data/lib/relaton/workers_pool.rb +0 -23
- data/spec/vcr_cassetes/cie_001_1980.yml +0 -120
- data/spec/vcr_cassetes/ecma_6.yml +0 -159
- data/spec/vcr_cassetes/hist_cmbined_included.yml +0 -105
- data/spec/vcr_cassetes/iec_60050_102_2007.yml +0 -285
- data/spec/vcr_cassetes/iec_combined_included.yml +0 -945
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -361
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -361
- data/spec/vcr_cassetes/itu_combined_included.yml +0 -1296
- data/spec/vcr_cassetes/rfc_unsuccess.yml +0 -70
data/spec/relaton/db_spec.rb
CHANGED
@@ -1,121 +1,6 @@
|
|
1
1
|
RSpec.describe Relaton::Db do
|
2
2
|
before(:each) { FileUtils.rm_rf %w[testcache testcache2] }
|
3
3
|
|
4
|
-
context "modifing database" do
|
5
|
-
let(:db) { Relaton::Db.new "testcache", "testcache2" }
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
db.save_entry "ISO(ISO 123)", "<bibitem id='ISO123></bibitem>"
|
9
|
-
end
|
10
|
-
|
11
|
-
context "move to new dir" do
|
12
|
-
let(:db) { Relaton::Db.new "global_cache", "local_cache" }
|
13
|
-
|
14
|
-
after(:each) do
|
15
|
-
FileUtils.rm_rf "global_cache"
|
16
|
-
FileUtils.rm_rf "local_cache"
|
17
|
-
end
|
18
|
-
|
19
|
-
it "global cache" do
|
20
|
-
expect(File.exist?("global_cache")).to be true
|
21
|
-
expect(db.mv("testcache")).to eq "testcache"
|
22
|
-
expect(File.exist?("testcache")).to be true
|
23
|
-
expect(File.exist?("global_cache")).to be false
|
24
|
-
end
|
25
|
-
|
26
|
-
it "local cache" do
|
27
|
-
expect(File.exist?("local_cache")).to be true
|
28
|
-
expect(db.mv("testcache2", type: :local)).to eq "testcache2"
|
29
|
-
expect(File.exist?("testcache2")).to be true
|
30
|
-
expect(File.exist?("local_cache")).to be false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "warn if moving in existed dir" do
|
35
|
-
expect(File).to receive(:exist?).with("new_cache_dir")
|
36
|
-
.and_return true
|
37
|
-
expect do
|
38
|
-
expect(db.mv("new_cache_dir")).to be_nil
|
39
|
-
end.to output(/\[relaton\] WARNING: target directory exists/).to_stderr
|
40
|
-
end
|
41
|
-
|
42
|
-
it "clear" do
|
43
|
-
expect(File.exist?("testcache/iso")).to be true
|
44
|
-
expect(File.exist?("testcache2/iso")).to be true
|
45
|
-
db.clear
|
46
|
-
expect(File.exist?("testcache/iso")).to be false
|
47
|
-
expect(File.exist?("testcache2/iso")).to be false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "query in local DB" do
|
52
|
-
let(:db) { Relaton::Db.new "testcache", "testcache2" }
|
53
|
-
|
54
|
-
before(:each) do
|
55
|
-
db.save_entry "ISO(ISO 123)", <<~DOC
|
56
|
-
<bibitem id='ISO123'>
|
57
|
-
<title>The first test</title><edition>2</edition><date type="published"><on>2011-10-12</on></date>
|
58
|
-
</bibitem>
|
59
|
-
DOC
|
60
|
-
db.save_entry "IEC(IEC 123)", <<~DOC
|
61
|
-
<bibitem id="IEC123">
|
62
|
-
<title>The second test</title><edition>1</edition><date type="published"><on>2015-12</on></date>
|
63
|
-
</bibitem>
|
64
|
-
DOC
|
65
|
-
end
|
66
|
-
|
67
|
-
after(:each) { db.clear }
|
68
|
-
|
69
|
-
it "one document" do
|
70
|
-
item = db.fetch_db "ISO((ISO 124)"
|
71
|
-
expect(item).to be_nil
|
72
|
-
item = db.fetch_db "ISO(ISO 123)"
|
73
|
-
expect(item).to be_instance_of RelatonIsoBib::IsoBibliographicItem
|
74
|
-
end
|
75
|
-
|
76
|
-
it "all documents" do
|
77
|
-
items = db.fetch_all
|
78
|
-
expect(items.size).to be 9
|
79
|
-
expect(items[7]).to be_instance_of RelatonIec::IecBibliographicItem
|
80
|
-
expect(items[8]).to be_instance_of RelatonIsoBib::IsoBibliographicItem
|
81
|
-
end
|
82
|
-
|
83
|
-
context "search for text" do
|
84
|
-
it do
|
85
|
-
items = db.fetch_all "test"
|
86
|
-
expect(items.size).to eq 2
|
87
|
-
items = db.fetch_all "first"
|
88
|
-
expect(items.size).to eq 1
|
89
|
-
expect(items[0].id).to eq "ISO123"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "in attributes" do
|
93
|
-
items = db.fetch_all "123"
|
94
|
-
expect(items.size).to eq 2
|
95
|
-
items = db.fetch_all "ISO"
|
96
|
-
expect(items.size).to eq 8
|
97
|
-
expect(items[7].id).to eq "ISO123"
|
98
|
-
end
|
99
|
-
|
100
|
-
it "and fail" do
|
101
|
-
items = db.fetch_all "bibitem"
|
102
|
-
expect(items.size).to eq 0
|
103
|
-
end
|
104
|
-
|
105
|
-
it "and edition" do
|
106
|
-
items = db.fetch_all "123", edition: "2"
|
107
|
-
expect(items.size).to eq 1
|
108
|
-
expect(items[0].id).to eq "ISO123"
|
109
|
-
end
|
110
|
-
|
111
|
-
it "and year" do
|
112
|
-
items = db.fetch_all "123", year: 2015
|
113
|
-
expect(items.size).to eq 1
|
114
|
-
expect(items[0].id).to eq "IEC123"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
4
|
it "returns docid type" do
|
120
5
|
db = Relaton::Db.new "testcache", "testcache2"
|
121
6
|
expect(db.docid_type("CN(GB/T 1.1)")).to eq ["Chinese Standard", "GB/T 1.1"]
|
@@ -145,36 +30,6 @@ RSpec.describe Relaton::Db do
|
|
145
30
|
end
|
146
31
|
end
|
147
32
|
|
148
|
-
it "fetch document with net retries" do
|
149
|
-
db = Relaton::Db.new nil, nil
|
150
|
-
expect(db.instance_variable_get(:@registry).processors[:relaton_ietf]).to receive(:get)
|
151
|
-
.and_raise(RelatonBib::RequestError).exactly(3).times
|
152
|
-
expect { db.fetch "RFC 8341", nil, retries: 3 }.to raise_error RelatonBib::RequestError
|
153
|
-
end
|
154
|
-
|
155
|
-
context "async fetch" do
|
156
|
-
let(:db) { Relaton::Db.new nil, nil }
|
157
|
-
let(:queue) { Queue.new }
|
158
|
-
|
159
|
-
it "success" do
|
160
|
-
result = nil
|
161
|
-
VCR.use_cassette "rfc_8341" do
|
162
|
-
db.fetch_async("RFC 8341") { |r| queue << r }
|
163
|
-
Timeout.timeout(5) { result = queue.pop }
|
164
|
-
end
|
165
|
-
expect(result).to be_instance_of RelatonIetf::IetfBibliographicItem
|
166
|
-
end
|
167
|
-
|
168
|
-
it "prefix not found" do
|
169
|
-
result = ""
|
170
|
-
VCR.use_cassette "rfc_unsuccess" do
|
171
|
-
db.fetch_async("ABC 123456") { |r| queue << r }
|
172
|
-
Timeout.timeout(5) { result = queue.pop }
|
173
|
-
end
|
174
|
-
expect(result).to be_nil
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
33
|
context "fetch documents form static cache" do
|
179
34
|
let(:db) { Relaton::Db.new nil, nil }
|
180
35
|
|
@@ -23,9 +23,5 @@ RSpec.describe Relaton::Processor do
|
|
23
23
|
it "hash_to_bib method should be implemented" do
|
24
24
|
expect { subject.hash_to_bib({}) }.to raise_error StandardError
|
25
25
|
end
|
26
|
-
|
27
|
-
it "grammar_hash method should be implemented" do
|
28
|
-
expect { subject.grammar_hash }.to raise_error StandardError
|
29
|
-
end
|
30
26
|
end
|
31
27
|
end
|
@@ -2,82 +2,72 @@ RSpec.describe Relaton::Registry do
|
|
2
2
|
it "outputs backend not present" do
|
3
3
|
stub_const "Relaton::Registry::SUPPORTED_GEMS", ["not_supported_gem"]
|
4
4
|
expect { Relaton::Registry.clone.instance }.to output(
|
5
|
-
/backend not_supported_gem not present
|
5
|
+
/backend not_supported_gem not present/,
|
6
6
|
).to_stdout
|
7
7
|
end
|
8
8
|
|
9
9
|
it "finds ISO processor" do
|
10
|
-
expect(Relaton::Registry.instance.find_processor("relaton_iso"))
|
11
|
-
|
10
|
+
expect(Relaton::Registry.instance.find_processor("relaton_iso")).
|
11
|
+
to be_instance_of RelatonIso::Processor
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns supported processors" do
|
15
15
|
expect(Relaton::Registry.instance.supported_processors).to include :relaton_iso
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
it "IEC" do
|
24
|
-
expect(Relaton::Registry.instance.by_type("IEC")).to be_instance_of RelatonIec::Processor
|
25
|
-
end
|
26
|
-
|
27
|
-
it "IETF" do
|
28
|
-
expect(Relaton::Registry.instance.by_type("IETF")).to be_instance_of RelatonIetf::Processor
|
29
|
-
end
|
18
|
+
it "finds processor by type" do
|
19
|
+
expect(Relaton::Registry.instance.by_type("CN")).to be_instance_of RelatonGb::Processor
|
20
|
+
end
|
30
21
|
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
it "finds processor by type" do
|
23
|
+
expect(Relaton::Registry.instance.by_type("IEC")).to be_instance_of RelatonIec::Processor
|
24
|
+
end
|
34
25
|
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
it "finds processor by type" do
|
27
|
+
expect(Relaton::Registry.instance.by_type("IETF")).to be_instance_of RelatonIetf::Processor
|
28
|
+
end
|
38
29
|
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
it "finds processor by type" do
|
31
|
+
expect(Relaton::Registry.instance.by_type("ISO")).to be_instance_of RelatonIso::Processor
|
32
|
+
end
|
42
33
|
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
it "finds processor by type" do
|
35
|
+
expect(Relaton::Registry.instance.by_type("ITU")).to be_instance_of RelatonItu::Processor
|
36
|
+
end
|
46
37
|
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
it "finds processor by type" do
|
39
|
+
expect(Relaton::Registry.instance.by_type("NIST")).to be_instance_of RelatonNist::Processor
|
40
|
+
end
|
50
41
|
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
it "finds processor by type" do
|
43
|
+
expect(Relaton::Registry.instance.by_type("OGC")).to be_instance_of RelatonOgc::Processor
|
44
|
+
end
|
54
45
|
|
55
|
-
|
56
|
-
|
57
|
-
|
46
|
+
it "finds processor by type" do
|
47
|
+
expect(Relaton::Registry.instance.by_type("CC")).to be_instance_of RelatonCalconnect::Processor
|
48
|
+
end
|
58
49
|
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
it "finds processor by type" do
|
51
|
+
expect(Relaton::Registry.instance.by_type("OMG")).to be_instance_of RelatonOmg::Processor
|
52
|
+
end
|
62
53
|
|
63
|
-
|
64
|
-
|
65
|
-
|
54
|
+
it "finds processor by type" do
|
55
|
+
expect(Relaton::Registry.instance.by_type("UN")).to be_instance_of RelatonUn::Processor
|
56
|
+
end
|
66
57
|
|
67
|
-
|
68
|
-
|
69
|
-
|
58
|
+
it "finds processor by type" do
|
59
|
+
expect(Relaton::Registry.instance.by_type("W3C")).to be_instance_of RelatonW3c::Processor
|
60
|
+
end
|
70
61
|
|
71
|
-
|
72
|
-
|
73
|
-
|
62
|
+
it "finds processor by type" do
|
63
|
+
expect(Relaton::Registry.instance.by_type("IEEE")).to be_instance_of RelatonIeee::Processor
|
64
|
+
end
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
|
66
|
+
it "finds processor by type" do
|
67
|
+
expect(Relaton::Registry.instance.by_type("IHO")).to be_instance_of RelatonIho::Processor
|
68
|
+
end
|
78
69
|
|
79
|
-
|
80
|
-
|
81
|
-
end
|
70
|
+
it "finds processor by type" do
|
71
|
+
expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of RelatonBipm::Processor
|
82
72
|
end
|
83
73
|
end
|
data/spec/relaton_spec.rb
CHANGED
@@ -58,28 +58,12 @@ RSpec.describe Relaton::Db do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
62
|
-
it "gets sn ISO/AWI reference" do
|
63
|
-
VCR.use_cassette "iso_awi_24229" do
|
64
|
-
bib = @db.fetch "ISO/AWI 24229"
|
65
|
-
expect(bib).not_to be_nil
|
66
|
-
end
|
67
|
-
end
|
68
61
|
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
it "get by URN" do
|
79
|
-
VCR.use_cassette "iec_60050_102_2007" do
|
80
|
-
bib = @db.fetch "urn:iec:std:iec:60050-102:2007:::"
|
81
|
-
expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
|
82
|
-
end
|
63
|
+
it "gets sn ISO/AWI reference" do
|
64
|
+
VCR.use_cassette "iso_awi_24229" do
|
65
|
+
bib = @db.fetch "ISO/AWI 24229"
|
66
|
+
expect(bib).not_to be_nil
|
83
67
|
end
|
84
68
|
end
|
85
69
|
|
@@ -264,115 +248,30 @@ RSpec.describe Relaton::Db do
|
|
264
248
|
end
|
265
249
|
end
|
266
250
|
|
267
|
-
it "get ECMA reference" do
|
268
|
-
VCR.use_cassette "ecma_6" do
|
269
|
-
bib = @db.fetch "ECMA-6"
|
270
|
-
expect(bib).to be_instance_of RelatonBib::BibliographicItem
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
it "get CIE reference" do
|
275
|
-
VCR.use_cassette "cie_001_1980" do
|
276
|
-
bib = @db.fetch "CIE 001-1980"
|
277
|
-
expect(bib).to be_instance_of RelatonBib::BibliographicItem
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
context "get combined documents" do
|
282
|
-
context "ISO" do
|
283
|
-
it "included" do
|
284
|
-
VCR.use_cassette "iso_combined_included" do
|
285
|
-
bib = @db.fetch "ISO 19115-1 + Amd 1"
|
286
|
-
expect(bib.docidentifier[0].id).to eq "ISO 19115-1 + Amd 1"
|
287
|
-
expect(bib.relation[0].type).to eq "updates"
|
288
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1"
|
289
|
-
expect(bib.relation[1].type).to eq "derivedFrom"
|
290
|
-
expect(bib.relation[1].description).to be_nil
|
291
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1/Amd 1:2018"
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
it "applied" do
|
296
|
-
VCR.use_cassette "iso_combined_applied" do
|
297
|
-
bib = @db.fetch "ISO 19115-1, Amd 1"
|
298
|
-
expect(bib.docidentifier[0].id).to eq "ISO 19115-1, Amd 1"
|
299
|
-
expect(bib.relation[0].type).to eq "updates"
|
300
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1"
|
301
|
-
expect(bib.relation[1].type).to eq "complements"
|
302
|
-
expect(bib.relation[1].description.content).to eq "amendment"
|
303
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1/Amd 1:2018"
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
context "IEC" do
|
309
|
-
it "included" do
|
310
|
-
VCR.use_cassette "iec_combined_included" do
|
311
|
-
bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
|
312
|
-
expect(bib.docidentifier[0].id).to eq "IEC 60027-1, Amd 1, Amd 2"
|
313
|
-
expect(bib.relation[0].type).to eq "updates"
|
314
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "IEC 60027-1"
|
315
|
-
expect(bib.relation[1].type).to eq "complements"
|
316
|
-
expect(bib.relation[1].description.content).to eq "amendment"
|
317
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD1:1997"
|
318
|
-
expect(bib.relation[2].type).to eq "complements"
|
319
|
-
expect(bib.relation[2].description.content).to eq "amendment"
|
320
|
-
expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD2:2005"
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
context "ITU" do
|
326
|
-
it "included" do
|
327
|
-
VCR.use_cassette "itu_combined_included" do
|
328
|
-
bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
|
329
|
-
expect(bib.docidentifier[0].id).to eq "ITU-T G.989.2, Amd 1, Amd 2"
|
330
|
-
expect(bib.relation[0].type).to eq "updates"
|
331
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2"
|
332
|
-
expect(bib.relation[1].type).to eq "complements"
|
333
|
-
expect(bib.relation[1].description.content).to eq "amendment"
|
334
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2/Amd 1"
|
335
|
-
expect(bib.relation[2].type).to eq "complements"
|
336
|
-
expect(bib.relation[2].description.content).to eq "amendment"
|
337
|
-
expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2/Amd 2"
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
context "HIST" do
|
343
|
-
it "included" do
|
344
|
-
VCR.use_cassette "hist_cmbined_included" do
|
345
|
-
bib = @db.fetch "NIST SP 800-38A, Add"
|
346
|
-
expect(bib.docidentifier[0].id).to eq "NIST SP 800-38A, Add"
|
347
|
-
expect(bib.relation[0].type).to eq "updates"
|
348
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "SP 800-38A"
|
349
|
-
expect(bib.relation[1].type).to eq "complements"
|
350
|
-
expect(bib.relation[1].description.content).to eq "amendment"
|
351
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "SP 800-38A-Add"
|
352
|
-
end
|
353
|
-
end
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
251
|
context "version control" do
|
358
|
-
before(:each) { @db.save_entry "iso(test_key)", "
|
252
|
+
before(:each) { @db.save_entry "iso(test_key)", value: "test_value" }
|
359
253
|
|
360
254
|
it "shoudn't clear cacho if version isn't changed" do
|
361
|
-
|
255
|
+
db = Relaton::Db.new "testcache", "testcache2"
|
256
|
+
testcache = db.instance_variable_get :@db
|
362
257
|
expect(testcache.all).to be_any
|
363
|
-
testcache =
|
258
|
+
testcache = db.instance_variable_get :@local_db
|
364
259
|
expect(testcache.all).to be_any
|
365
260
|
end
|
366
261
|
|
367
262
|
it "should clear cache if version is changed" do
|
368
|
-
expect(File.
|
369
|
-
expect(File.
|
263
|
+
expect(File.exist?("testcache")).to be true
|
264
|
+
expect(File.exist?("testcache2")).to be true
|
370
265
|
processor = double
|
371
|
-
expect(processor).to receive(:grammar_hash).and_return("new_version")
|
372
|
-
|
373
|
-
Relaton::
|
374
|
-
|
375
|
-
|
266
|
+
expect(processor).to receive(:grammar_hash).and_return("new_version")
|
267
|
+
.exactly(2).times
|
268
|
+
expect(Relaton::Registry.instance).to receive(:by_type)
|
269
|
+
.and_return(processor).exactly(2).times
|
270
|
+
db = Relaton::Db.new "testcache", "testcache2"
|
271
|
+
testcache = db.instance_variable_get :@db
|
272
|
+
expect(testcache.all).not_to be_any
|
273
|
+
testcache = db.instance_variable_get :@local_db
|
274
|
+
expect(testcache.all).not_to be_any
|
376
275
|
end
|
377
276
|
end
|
378
277
|
end
|