dwc-archive 0.9.10 → 1.1.2
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +2 -1
- data/.rubocop.yml +23 -0
- data/.ruby-version +1 -1
- data/.travis.yml +4 -7
- data/CHANGELOG +14 -8
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +119 -107
- data/Rakefile +13 -36
- data/dwc-archive.gemspec +23 -19
- data/features/step_definitions/dwc-creator_steps.rb +5 -5
- data/features/step_definitions/dwc-reader_steps.rb +47 -28
- data/features/support/env.rb +1 -1
- data/lib/dwc_archive.rb +124 -0
- data/lib/dwc_archive/archive.rb +60 -0
- data/lib/dwc_archive/classification_normalizer.rb +382 -0
- data/lib/dwc_archive/core.rb +25 -0
- data/lib/{dwc-archive → dwc_archive}/errors.rb +10 -0
- data/lib/dwc_archive/expander.rb +88 -0
- data/lib/{dwc-archive → dwc_archive}/extension.rb +5 -3
- data/lib/dwc_archive/generator.rb +91 -0
- data/lib/dwc_archive/generator_eml_xml.rb +116 -0
- data/lib/dwc_archive/generator_meta_xml.rb +72 -0
- data/lib/dwc_archive/gnub_taxon.rb +14 -0
- data/lib/dwc_archive/ingester.rb +106 -0
- data/lib/dwc_archive/metadata.rb +57 -0
- data/lib/dwc_archive/taxon_normalized.rb +23 -0
- data/lib/dwc_archive/version.rb +6 -0
- data/lib/dwc_archive/xml_reader.rb +90 -0
- data/spec/files/file with characters(3).gz b/data/spec/files/file with → characters(3).tar.gz +0 -0
- data/spec/files/generator_eml.xml +47 -0
- data/spec/files/generator_meta.xml +19 -0
- data/spec/lib/classification_normalizer_spec.rb +96 -105
- data/spec/lib/core_spec.rb +43 -41
- data/spec/lib/darwin_core_spec.rb +108 -138
- data/spec/lib/generator_eml_xml_spec.rb +12 -11
- data/spec/lib/generator_meta_xml_spec.rb +12 -11
- data/spec/lib/generator_spec.rb +77 -69
- data/spec/lib/gnub_taxon_spec.rb +15 -17
- data/spec/lib/metadata_spec.rb +50 -41
- data/spec/lib/taxon_normalized_spec.rb +62 -65
- data/spec/lib/xml_reader_spec.rb +9 -12
- data/spec/spec_helper.rb +54 -51
- metadata +105 -88
- data/.rvmrc +0 -1
- data/] +0 -40
- data/lib/dwc-archive.rb +0 -107
- data/lib/dwc-archive/archive.rb +0 -40
- data/lib/dwc-archive/classification_normalizer.rb +0 -428
- data/lib/dwc-archive/core.rb +0 -17
- data/lib/dwc-archive/expander.rb +0 -84
- data/lib/dwc-archive/generator.rb +0 -85
- data/lib/dwc-archive/generator_eml_xml.rb +0 -86
- data/lib/dwc-archive/generator_meta_xml.rb +0 -58
- data/lib/dwc-archive/ingester.rb +0 -101
- data/lib/dwc-archive/metadata.rb +0 -48
- data/lib/dwc-archive/version.rb +0 -3
- data/lib/dwc-archive/xml_reader.rb +0 -64
data/spec/lib/core_spec.rb
CHANGED
@@ -1,97 +1,99 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../spec_helper"
|
2
4
|
|
3
5
|
describe DarwinCore::Core do
|
4
6
|
subject(:dwca) { DarwinCore.new(file_path) }
|
5
7
|
subject(:core) { DarwinCore::Core.new(dwca) }
|
6
|
-
let(:file_path)
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
let(:file_path) do
|
9
|
+
File.join(File.expand_path("../files", __dir__), file_name)
|
10
|
+
end
|
11
|
+
let(:file_name) { "data.tar.gz" }
|
10
12
|
|
11
|
-
describe
|
12
|
-
it
|
13
|
+
describe ".new" do
|
14
|
+
it "creates new core" do
|
13
15
|
expect(core).to be_kind_of DarwinCore::Core
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
17
|
-
describe '#id' do
|
18
18
|
|
19
|
-
|
19
|
+
describe "#id" do
|
20
|
+
it "returns core id" do
|
20
21
|
expect(core.id[:index]).to eq 0
|
21
|
-
expect(core.id[:term]).to eq
|
22
|
+
expect(core.id[:term]).to eq "http://rs.tdwg.org/dwc/terms/TaxonID"
|
22
23
|
end
|
23
24
|
|
24
|
-
context
|
25
|
-
let(:file_name) {
|
25
|
+
context "no coreid" do
|
26
|
+
let(:file_name) { "empty_coreid.tar.gz" }
|
26
27
|
|
27
|
-
it
|
28
|
+
it "does not return coreid" do
|
28
29
|
expect(core.id[:index]).to eq 0
|
29
30
|
expect(core.id[:term]).to be_nil
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
describe
|
35
|
-
it
|
35
|
+
describe "#data" do
|
36
|
+
it "gers core data" do
|
36
37
|
expect(core.data).to be_kind_of Hash
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
describe
|
41
|
-
it
|
41
|
+
describe "#properties" do
|
42
|
+
it "gers core properties" do
|
42
43
|
expect(core.properties).to be_kind_of Hash
|
43
|
-
expect(core.properties.keys).to match_array [
|
44
|
-
|
45
|
-
|
44
|
+
expect(core.properties.keys).to match_array %i[
|
45
|
+
encoding fieldsTerminatedBy linesTerminatedBy fieldsEnclosedBy
|
46
|
+
ignoreHeaderLines rowType
|
47
|
+
]
|
46
48
|
end
|
47
49
|
end
|
48
|
-
|
49
|
-
describe
|
50
|
-
it
|
51
|
-
expect(core.encoding).to eq
|
50
|
+
|
51
|
+
describe "#encoding" do
|
52
|
+
it "returns encoding of the data" do
|
53
|
+
expect(core.encoding).to eq "UTF-8"
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
describe
|
56
|
-
it
|
57
|
+
describe "#fields_separator" do
|
58
|
+
it "returns separator of fields for csv files" do
|
57
59
|
expect(core.fields_separator).to be_nil
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
describe
|
62
|
-
it
|
63
|
+
describe "#size" do
|
64
|
+
it "returns number of lines in the core" do
|
63
65
|
expect(core.size).to eq 588
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
describe
|
68
|
-
it
|
69
|
-
expect(core.file_path).to match
|
69
|
+
describe "#file_path" do
|
70
|
+
it "returns file path of core file" do
|
71
|
+
expect(core.file_path).to match "DarwinCore.txt"
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
describe
|
74
|
-
it
|
75
|
+
describe "#fields" do
|
76
|
+
it "returns fields of the core file" do
|
75
77
|
expect(core.fields.size).to eq 7
|
76
78
|
expect(core.fields).to be_kind_of Array
|
77
79
|
expect(core.fields[0]).to be_kind_of Hash
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
|
-
describe
|
82
|
-
it
|
83
|
+
describe "#line_separator" do
|
84
|
+
it "returns characters separating lines in csv file" do
|
83
85
|
expect(core.line_separator).to eq "\\n"
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
87
|
-
describe
|
88
|
-
it
|
89
|
-
expect(core.quote_character).to eq
|
89
|
+
describe "#quote_character" do
|
90
|
+
it "returns quote character for the csv file" do
|
91
|
+
expect(core.quote_character).to eq ""
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
93
|
-
describe
|
94
|
-
it
|
95
|
+
describe "#ignore headers" do
|
96
|
+
it "returns true if headers should not be included into data" do
|
95
97
|
expect(core.ignore_headers).to eq true
|
96
98
|
end
|
97
99
|
end
|
@@ -1,279 +1,249 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe DarwinCore do
|
4
4
|
subject { DarwinCore }
|
5
|
-
let(:file_dir) { File.expand_path(
|
5
|
+
let(:file_dir) { File.expand_path("../files", __dir__) }
|
6
6
|
|
7
|
-
it
|
8
|
-
|
9
|
-
expect{load File.expand_path('../../../lib/dwc-archive.rb', __FILE__)}.
|
10
|
-
to raise_error
|
7
|
+
it "has version" do
|
8
|
+
expect(DarwinCore::VERSION).to match(/\d+\.\d+\.\d/)
|
11
9
|
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'redis connection' do
|
20
|
-
it 'redis is running' do
|
21
|
-
expect do
|
22
|
-
socket = TCPSocket.open('localhost', 6379)
|
23
|
-
socket.close
|
24
|
-
end.to_not raise_error
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'has version' do
|
29
|
-
expect(DarwinCore::VERSION =~ /\d+\.\d+\.\d/).to be_true
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '.nil_field?' do
|
33
|
-
it 'is true for nil fields' do
|
34
|
-
[nil, '/N', ''].each do |i|
|
35
|
-
expect(DarwinCore.nil_field?(i)).to be_true
|
11
|
+
describe ".nil_field?" do
|
12
|
+
it "is true for nil fields" do
|
13
|
+
[nil, "/N", ""].each do |i|
|
14
|
+
expect(DarwinCore.nil_field?(i)).to be true
|
36
15
|
end
|
37
16
|
end
|
38
17
|
|
39
|
-
it
|
40
|
-
[0,
|
41
|
-
expect(subject.nil_field?(i)).to
|
18
|
+
it "is false for non-nil fields" do
|
19
|
+
[0, "0", "123", 123, "dsdfs434343/N"].each do |i|
|
20
|
+
expect(subject.nil_field?(i)).to be false
|
42
21
|
end
|
43
22
|
end
|
44
23
|
end
|
45
24
|
|
46
|
-
describe
|
25
|
+
describe ".clean_all" do
|
47
26
|
let(:tmp_dir) { DarwinCore::DEFAULT_TMP_DIR }
|
48
27
|
|
49
|
-
it
|
28
|
+
it "cleans dwca directories" do
|
50
29
|
Dir.chdir(tmp_dir)
|
51
|
-
FileUtils.mkdir(
|
52
|
-
dwca_dirs =
|
30
|
+
FileUtils.mkdir("dwc_123") unless File.exist?("dwc_123")
|
31
|
+
dwca_dirs = Dir.entries(tmp_dir).select { |d| d.match(/^dwc_\d+$/) }
|
53
32
|
expect(dwca_dirs.size).to be > 0
|
54
33
|
subject.clean_all
|
55
|
-
dwca_dirs =
|
34
|
+
dwca_dirs = Dir.entries(tmp_dir).select { |d| d.match(/^dwc_\d+$/) }
|
56
35
|
expect(dwca_dirs.size).to be 0
|
57
36
|
end
|
58
37
|
|
59
|
-
context
|
60
|
-
it
|
38
|
+
context "no dwc files exist" do
|
39
|
+
it "does nothing" do
|
61
40
|
subject.clean_all
|
62
41
|
subject.clean_all
|
63
|
-
dwca_dirs =
|
42
|
+
dwca_dirs = Dir.entries(tmp_dir).select { |d| d.match(/^dwc_\d+$/) }
|
64
43
|
expect(dwca_dirs.size).to be 0
|
65
44
|
end
|
66
45
|
end
|
67
46
|
end
|
68
47
|
|
69
|
-
describe
|
48
|
+
describe ".logger" do
|
70
49
|
it { expect(subject.logger).to be_kind_of Logger }
|
71
50
|
end
|
72
51
|
|
73
|
-
describe
|
74
|
-
it
|
75
|
-
expect(subject.logger =
|
76
|
-
expect(subject.logger).to eq
|
52
|
+
describe ".logger=" do
|
53
|
+
it "sets logger" do
|
54
|
+
expect(subject.logger = "fake logger").to eq "fake logger"
|
55
|
+
expect(subject.logger).to eq "fake logger"
|
77
56
|
end
|
78
57
|
end
|
79
58
|
|
80
|
-
describe
|
81
|
-
it
|
82
|
-
subject.logger =
|
83
|
-
expect(subject.logger).to eq
|
59
|
+
describe ".logger_reset" do
|
60
|
+
it "resets logger" do
|
61
|
+
subject.logger = "fake logger"
|
62
|
+
expect(subject.logger).to eq "fake logger"
|
84
63
|
subject.logger_reset
|
85
64
|
expect(subject.logger).to be_kind_of Logger
|
86
65
|
end
|
87
66
|
end
|
88
67
|
|
89
|
-
describe
|
68
|
+
describe ".new" do
|
90
69
|
subject(:dwca) { DarwinCore.new(file_path) }
|
91
|
-
|
92
|
-
context
|
93
|
-
files = %w
|
70
|
+
|
71
|
+
context "tar.gz and zip files supplied" do
|
72
|
+
files = %w[data.zip data.tar.gz minimal.tar.gz junk_dir_inside.zip]
|
94
73
|
files.each do |file|
|
95
74
|
let(:file_path) { File.join(file_dir, file) }
|
96
75
|
|
97
|
-
it "creates archive from
|
98
|
-
expect(dwca.archive.valid?).to
|
76
|
+
it "creates archive from #{file}" do
|
77
|
+
expect(dwca.archive.valid?).to be true
|
99
78
|
end
|
100
|
-
|
101
79
|
end
|
102
80
|
end
|
103
81
|
|
104
|
-
context
|
105
|
-
let(:file_path) { File.join(file_dir,
|
82
|
+
context "when file does not exist" do
|
83
|
+
let(:file_path) { File.join(file_dir, "no_file.gz") }
|
106
84
|
|
107
|
-
it
|
108
|
-
|
85
|
+
it "raises not found" do
|
86
|
+
expect { dwca }.to raise_error DarwinCore::FileNotFoundError
|
109
87
|
end
|
110
88
|
end
|
111
89
|
|
112
|
-
context
|
90
|
+
context "archive cannot unpack" do
|
91
|
+
let(:file_path) { File.join(file_dir, "broken.tar.gz") }
|
113
92
|
|
114
|
-
|
115
|
-
|
116
|
-
it 'raises unpacking error' do
|
93
|
+
it "raises unpacking error" do
|
117
94
|
expect { dwca }.to raise_error DarwinCore::UnpackingError
|
118
95
|
end
|
119
96
|
end
|
120
97
|
|
121
|
-
context
|
122
|
-
|
123
|
-
let(:file_path) { File.join(file_dir, 'invalid.tar.gz') }
|
98
|
+
context "archive is broken" do
|
99
|
+
let(:file_path) { File.join(file_dir, "invalid.tar.gz") }
|
124
100
|
|
125
|
-
it
|
101
|
+
it "raises error of invalid archive" do
|
126
102
|
expect { dwca }.to raise_error DarwinCore::InvalidArchiveError
|
127
103
|
end
|
128
|
-
|
129
104
|
end
|
130
|
-
|
131
|
-
context 'archive is not in utf-8 encoding' do
|
132
105
|
|
133
|
-
|
134
|
-
|
135
|
-
|
106
|
+
context "archive is not in utf-8 encoding" do
|
107
|
+
let(:file_path) { File.join(file_dir, "latin1.tar.gz") }
|
108
|
+
|
109
|
+
it "raises wrong encoding error" do
|
136
110
|
expect { dwca }.to raise_error DarwinCore::EncodingError
|
137
111
|
end
|
138
|
-
|
139
112
|
end
|
140
|
-
|
141
|
-
context 'filename with spaces and non-alphanumeric chars' do
|
142
113
|
|
143
|
-
|
144
|
-
|
145
|
-
it 'creates archive' do
|
146
|
-
expect(dwca.archive.valid?).to be_true
|
147
|
-
end
|
114
|
+
context "filename with spaces and non-alphanumeric chars" do
|
115
|
+
let(:file_path) { File.join(file_dir, "file with characters(3).tar.gz") }
|
148
116
|
|
117
|
+
it "creates archive" do
|
118
|
+
expect(dwca.archive.valid?).to be true
|
119
|
+
end
|
149
120
|
end
|
150
121
|
end
|
151
122
|
|
152
|
-
describe
|
123
|
+
describe "file_name" do
|
153
124
|
subject(:dwca) { DarwinCore.new(file_path) }
|
154
|
-
let(:file_path) { File.join(file_dir,
|
125
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
155
126
|
|
156
|
-
it
|
157
|
-
expect(dwca.file_name).to eq
|
127
|
+
it "returns file name" do
|
128
|
+
expect(dwca.file_name).to eq "data.tar.gz"
|
158
129
|
end
|
159
130
|
end
|
160
131
|
|
161
|
-
describe
|
132
|
+
describe "path" do
|
162
133
|
subject(:dwca) { DarwinCore.new(file_path) }
|
163
|
-
let(:file_path) { File.join(file_dir,
|
134
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
164
135
|
|
165
|
-
it
|
166
|
-
expect(dwca.path).to match
|
136
|
+
it "returns path of the archive" do
|
137
|
+
expect(dwca.path).to match(/spec.files.data\.tar\.gz/)
|
167
138
|
end
|
168
139
|
end
|
169
140
|
|
170
|
-
describe
|
141
|
+
describe "#archive" do
|
171
142
|
subject(:dwca) { DarwinCore.new(file_path) }
|
172
|
-
let(:file_path) { File.join(file_dir,
|
143
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
173
144
|
|
174
|
-
it
|
145
|
+
it "returns archive" do
|
175
146
|
expect(dwca.archive).to be_kind_of DarwinCore::Archive
|
176
147
|
end
|
177
148
|
end
|
178
149
|
|
179
|
-
describe
|
150
|
+
describe "#core" do
|
180
151
|
subject(:dwca) { DarwinCore.new(file_path) }
|
181
|
-
let(:file_path) { File.join(file_dir,
|
152
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
182
153
|
|
183
|
-
it
|
154
|
+
it "returns core" do
|
184
155
|
expect(dwca.core).to be_kind_of DarwinCore::Core
|
185
156
|
end
|
186
157
|
end
|
187
158
|
|
188
|
-
describe
|
159
|
+
describe "#metadata" do
|
189
160
|
subject(:dwca) { DarwinCore.new(file_path) }
|
190
|
-
let(:file_path) { File.join(file_dir,
|
161
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
191
162
|
|
192
|
-
it
|
163
|
+
it "returns eml" do
|
193
164
|
expect(dwca.eml).to be_kind_of DarwinCore::Metadata
|
194
165
|
expect(dwca.metadata).to be_kind_of DarwinCore::Metadata
|
195
166
|
end
|
196
167
|
end
|
197
|
-
|
198
|
-
describe
|
168
|
+
|
169
|
+
describe "#extensions" do
|
199
170
|
subject(:dwca) { DarwinCore.new(file_path) }
|
200
|
-
let(:file_path) { File.join(file_dir,
|
171
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
201
172
|
|
202
|
-
it
|
173
|
+
it "returns extensions" do
|
203
174
|
extensions = dwca.extensions
|
204
175
|
expect(extensions).to be_kind_of Array
|
205
|
-
expect(extensions[0]).to be_kind_of DarwinCore::Extension
|
176
|
+
expect(extensions[0]).to be_kind_of DarwinCore::Extension
|
206
177
|
end
|
207
178
|
end
|
208
179
|
|
209
|
-
describe
|
180
|
+
describe "#checksum" do
|
210
181
|
subject(:dwca) { DarwinCore.new(file_path) }
|
211
|
-
let(:file_path) { File.join(file_dir,
|
182
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
212
183
|
|
213
|
-
it
|
214
|
-
expect(dwca.checksum).to eq
|
184
|
+
it "creates checksum hash" do
|
185
|
+
expect(dwca.checksum).to eq "7d94fc28ffaf434b66fbc790aa5ef00d834057bf"
|
215
186
|
end
|
216
187
|
end
|
217
188
|
|
218
|
-
describe
|
189
|
+
describe "#parent_id?" do
|
219
190
|
subject(:dwca) { DarwinCore.new(file_path) }
|
220
191
|
|
221
|
-
context
|
222
|
-
let(:file_path) { File.join(file_dir,
|
223
|
-
it
|
224
|
-
expect(dwca.
|
192
|
+
context "has classification" do
|
193
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
194
|
+
it "returns true" do
|
195
|
+
expect(dwca.parent_id?).to be true
|
225
196
|
end
|
226
197
|
end
|
227
198
|
|
228
|
-
context
|
229
|
-
let(:file_path) { File.join(file_dir,
|
230
|
-
it
|
231
|
-
expect(dwca.
|
199
|
+
context "does not have classification" do
|
200
|
+
let(:file_path) { File.join(file_dir, "gnub.tar.gz") }
|
201
|
+
it "returns false" do
|
202
|
+
expect(dwca.parent_id?).to be false
|
232
203
|
end
|
233
204
|
end
|
234
205
|
end
|
235
206
|
|
236
|
-
describe
|
207
|
+
describe "#classification_normalizer" do
|
237
208
|
subject(:dwca) { DarwinCore.new(file_path) }
|
238
|
-
let(:file_path) { File.join(file_dir,
|
239
|
-
|
240
|
-
context
|
241
|
-
it
|
209
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
210
|
+
|
211
|
+
context "not initialized" do
|
212
|
+
it "is nil" do
|
242
213
|
expect(dwca.classification_normalizer).to be_nil
|
243
214
|
end
|
244
215
|
end
|
245
216
|
|
246
|
-
context
|
247
|
-
it
|
217
|
+
context "initialized" do
|
218
|
+
it "is DarwinCore::ClassificationNormalizer" do
|
248
219
|
dwca.normalize_classification
|
249
220
|
expect(dwca.classification_normalizer).
|
250
|
-
to be_kind_of DarwinCore::ClassificationNormalizer
|
221
|
+
to be_kind_of DarwinCore::ClassificationNormalizer
|
251
222
|
end
|
252
223
|
end
|
253
224
|
end
|
254
225
|
|
255
|
-
describe
|
226
|
+
describe "#normalize_classification" do
|
256
227
|
subject(:dwca) { DarwinCore.new(file_path) }
|
257
|
-
let(:file_path) { File.join(file_dir,
|
228
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
258
229
|
let(:normalized) { dwca.normalize_classification }
|
230
|
+
let(:encodings) do
|
231
|
+
normalized.each_with_object(Set.new) do |taxon, e|
|
232
|
+
taxon[1].classification_path.each { |p| e << p.encoding }
|
233
|
+
end
|
234
|
+
end
|
259
235
|
|
260
|
-
it
|
236
|
+
it "returns hash" do
|
261
237
|
expect(normalized).to be_kind_of Hash
|
262
238
|
end
|
263
239
|
|
264
|
-
it
|
265
|
-
encodings
|
266
|
-
normalized.each do |taxon_id, taxon|
|
267
|
-
taxon.classification_path.each { |p| encodings << p.encoding }
|
268
|
-
end
|
269
|
-
expect(encodings.uniq!.map { |e| e.to_s }).to eq ['UTF-8']
|
240
|
+
it "uses utf-8 encoding for classification paths" do
|
241
|
+
expect(encodings.map(&:to_s).to_a).to eq ["UTF-8"]
|
270
242
|
end
|
271
243
|
|
272
|
-
it
|
273
|
-
expect(normalized[
|
244
|
+
it "has elements of DarwinCore::TaxonNormalized type" do
|
245
|
+
expect(normalized["leptogastrinae:tid:2857"]).
|
274
246
|
to be_kind_of DarwinCore::TaxonNormalized
|
275
247
|
end
|
276
248
|
end
|
277
|
-
|
278
249
|
end
|
279
|
-
|