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.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -1
  4. data/.rubocop.yml +23 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +4 -7
  7. data/CHANGELOG +14 -8
  8. data/Gemfile +3 -1
  9. data/LICENSE +1 -1
  10. data/README.md +119 -107
  11. data/Rakefile +13 -36
  12. data/dwc-archive.gemspec +23 -19
  13. data/features/step_definitions/dwc-creator_steps.rb +5 -5
  14. data/features/step_definitions/dwc-reader_steps.rb +47 -28
  15. data/features/support/env.rb +1 -1
  16. data/lib/dwc_archive.rb +124 -0
  17. data/lib/dwc_archive/archive.rb +60 -0
  18. data/lib/dwc_archive/classification_normalizer.rb +382 -0
  19. data/lib/dwc_archive/core.rb +25 -0
  20. data/lib/{dwc-archive → dwc_archive}/errors.rb +10 -0
  21. data/lib/dwc_archive/expander.rb +88 -0
  22. data/lib/{dwc-archive → dwc_archive}/extension.rb +5 -3
  23. data/lib/dwc_archive/generator.rb +91 -0
  24. data/lib/dwc_archive/generator_eml_xml.rb +116 -0
  25. data/lib/dwc_archive/generator_meta_xml.rb +72 -0
  26. data/lib/dwc_archive/gnub_taxon.rb +14 -0
  27. data/lib/dwc_archive/ingester.rb +106 -0
  28. data/lib/dwc_archive/metadata.rb +57 -0
  29. data/lib/dwc_archive/taxon_normalized.rb +23 -0
  30. data/lib/dwc_archive/version.rb +6 -0
  31. data/lib/dwc_archive/xml_reader.rb +90 -0
  32. data/spec/files/file with characters(3).gz b/data/spec/files/file with → characters(3).tar.gz +0 -0
  33. data/spec/files/generator_eml.xml +47 -0
  34. data/spec/files/generator_meta.xml +19 -0
  35. data/spec/lib/classification_normalizer_spec.rb +96 -105
  36. data/spec/lib/core_spec.rb +43 -41
  37. data/spec/lib/darwin_core_spec.rb +108 -138
  38. data/spec/lib/generator_eml_xml_spec.rb +12 -11
  39. data/spec/lib/generator_meta_xml_spec.rb +12 -11
  40. data/spec/lib/generator_spec.rb +77 -69
  41. data/spec/lib/gnub_taxon_spec.rb +15 -17
  42. data/spec/lib/metadata_spec.rb +50 -41
  43. data/spec/lib/taxon_normalized_spec.rb +62 -65
  44. data/spec/lib/xml_reader_spec.rb +9 -12
  45. data/spec/spec_helper.rb +54 -51
  46. metadata +105 -88
  47. data/.rvmrc +0 -1
  48. data/] +0 -40
  49. data/lib/dwc-archive.rb +0 -107
  50. data/lib/dwc-archive/archive.rb +0 -40
  51. data/lib/dwc-archive/classification_normalizer.rb +0 -428
  52. data/lib/dwc-archive/core.rb +0 -17
  53. data/lib/dwc-archive/expander.rb +0 -84
  54. data/lib/dwc-archive/generator.rb +0 -85
  55. data/lib/dwc-archive/generator_eml_xml.rb +0 -86
  56. data/lib/dwc-archive/generator_meta_xml.rb +0 -58
  57. data/lib/dwc-archive/ingester.rb +0 -101
  58. data/lib/dwc-archive/metadata.rb +0 -48
  59. data/lib/dwc-archive/version.rb +0 -3
  60. data/lib/dwc-archive/xml_reader.rb +0 -64
@@ -1,21 +1,22 @@
1
- require_relative '../spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe DarwinCore::Generator::EmlXml do
4
- subject(:eml) { DarwinCore::Generator::EmlXml.new(data, path) }
4
+ subject { DarwinCore::Generator::EmlXml.new(data, path) }
5
5
  let(:data) { EML_DATA }
6
6
  let(:path) { DarwinCore::DEFAULT_TMP_DIR }
7
7
 
8
- describe '.new' do
9
- it 'initializes generator' do
10
- expect(eml).to be_kind_of DarwinCore::Generator::EmlXml
11
- end
8
+ describe ".new" do
9
+ it { is_expected.to be_kind_of DarwinCore::Generator::EmlXml }
12
10
  end
13
11
 
14
- describe '#create' do
15
- it 'should create eml xml' do
16
- eml.create
17
- eml_xml = File.read(File.join(path, 'eml.xml'))
18
- expect(eml_xml).to match /Test Classification/
12
+ describe "#create" do
13
+ let(:content) do
14
+ subject.create
15
+ File.read(File.join(path, "eml.xml"))
16
+ end
17
+
18
+ it "should create eml xml" do
19
+ expect(content).to match(/Test Classification/)
19
20
  end
20
21
  end
21
22
  end
@@ -1,21 +1,22 @@
1
- require_relative '../spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe DarwinCore::Generator::MetaXml do
4
- subject(:meta) { DarwinCore::Generator::MetaXml.new(data, path) }
4
+ subject { DarwinCore::Generator::MetaXml.new(data, path) }
5
5
  let(:data) { META_DATA }
6
6
  let(:path) { DarwinCore::DEFAULT_TMP_DIR }
7
7
 
8
- describe '.new' do
9
- it 'initializes' do
10
- expect(meta).to be_kind_of DarwinCore::Generator::MetaXml
11
- end
8
+ describe ".new" do
9
+ it { is_expected.to be_kind_of DarwinCore::Generator::MetaXml }
12
10
  end
13
11
 
14
- describe '#create' do
15
- it 'creates metadata file' do
16
- meta.create
17
- meta = File.read(File.join(path, 'meta.xml'))
18
- expect(meta).to match %r|<location>core.csv</location>|
12
+ describe "#create" do
13
+ let(:content) do
14
+ subject.create
15
+ File.read(File.join(path, "meta.xml"))
16
+ end
17
+
18
+ it "creates metadata file" do
19
+ expect(content).to match(%r{<location>core.csv</location>})
19
20
  end
20
21
  end
21
22
  end
@@ -1,116 +1,124 @@
1
- # encoding: utf-8
2
- require_relative '../spec_helper'
1
+ # frozen_string_literal: true
3
2
 
4
3
  describe DarwinCore::Generator do
5
4
  subject(:gen) { DarwinCore::Generator.new(dwc_path, tmp_dir) }
6
5
  let(:tmp_dir) { DarwinCore::DEFAULT_TMP_DIR }
7
- let(:dwc_path) { File.join(tmp_dir, 'spec_dwca.tar.gz') }
6
+ let(:dwc_path) { File.join(tmp_dir, "spec_dwca.tar.gz") }
8
7
 
9
- describe '.new' do
10
- it 'initializes empty DwCA' do
11
- expect(gen).to be_kind_of DarwinCore::Generator
8
+ def generate_dwca(gen)
9
+ gen.add_core(CORE_DATA.dup, "core.csv", true)
10
+ gen.add_extension(EXTENSION_DATA.dup, "vern.csv", true,
11
+ "http://rs.gbif.org/terms/1.0/VernacularName")
12
+ gen.add_meta_xml
13
+ gen.add_eml_xml(EML_DATA)
14
+ end
15
+
16
+ describe ".new" do
17
+ it "initializes empty DwCA" do
18
+ expect(gen).to be_kind_of DarwinCore::Generator
12
19
  end
13
20
  end
14
21
 
15
- describe '#add_core' do
16
- it 'adds core to DwCA instance' do
17
- gen.add_core(CORE_DATA.dup, 'core.csv', true)
18
- core = File.read(File.join(gen.path, 'core.csv'))
19
- expect(core).to match /taxonID,parentNameUsageID,scientificName/
22
+ describe "#add_core" do
23
+ it "adds core to DwCA instance" do
24
+ gen.add_core(CORE_DATA.dup, "core.csv", true)
25
+ core = File.read(File.join(gen.path, "core.csv"))
26
+ expect(core).to match(/taxonID,parentNameUsageID,scientificName/)
20
27
  end
21
28
 
22
- context 'urls are not given in header' do
23
- it 'raises error' do
29
+ context "urls are not given in header" do
30
+ it "raises error" do
24
31
  data = CORE_DATA.dup
25
- data[0] = data[0].map { |f| f.split('/')[-1] }
26
- expect { gen.add_core(data, 'core.csv', true) }.
27
- to raise_error DarwinCore::GeneratorError
32
+ data[0] = data[0].map { |f| f.split("/")[-1] }
33
+ expect { gen.add_core(data, "core.csv", true) }.
34
+ to raise_error DarwinCore::GeneratorError
28
35
  end
29
36
  end
30
37
  end
31
38
 
32
- describe '#add_extension' do
33
- it 'adds extension to DwCA instance' do
34
- gen.add_extension(EXTENSION_DATA.dup,
35
- 'vern.csv',
36
- true,
37
- 'http://rs.gbif.org/terms/1.0/VernacularName')
38
- extension = File.read(File.join(gen.path, 'vern.csv'))
39
-
40
- expect(extension).to match /Береза/
39
+ describe "#add_extension" do
40
+ it "adds extension to DwCA instance" do
41
+ gen.add_extension(EXTENSION_DATA.dup,
42
+ "vern.csv",
43
+ true,
44
+ "http://rs.gbif.org/terms/1.0/VernacularName")
45
+ extension = File.read(File.join(gen.path, "vern.csv"))
46
+
47
+ expect(extension).to match(/Береза/)
41
48
  end
42
49
  end
43
50
 
44
- describe '#add_meta_xml' do
45
- it 'creates metadata for DwCA' do
46
- gen.add_core(CORE_DATA.dup, 'core.csv', true)
47
- gen.add_extension(EXTENSION_DATA.dup,
48
- 'vern.csv',
49
- true,
50
- 'http://rs.gbif.org/terms/1.0/VernacularName')
51
+ describe "#add_meta_xml" do
52
+ it "creates metadata for DwCA" do
53
+ gen.add_core(CORE_DATA.dup, "core.csv", true)
54
+ gen.add_extension(EXTENSION_DATA.dup,
55
+ "vern.csv",
56
+ true,
57
+ "http://rs.gbif.org/terms/1.0/VernacularName")
51
58
 
52
59
  gen.add_meta_xml
53
- meta = File.read(File.join(gen.path, 'meta.xml'))
54
- expect(meta).to match %r|<location>core.csv</location>|
60
+ meta = File.read(File.join(gen.path, "meta.xml")).strip
61
+ meta_from_file = File.read(
62
+ File.expand_path("../files/generator_meta.xml", __dir__)
63
+ ).strip
64
+ expect(meta).to eq meta_from_file
55
65
  end
56
66
  end
57
67
 
58
- describe '#add_eml_data' do
59
- it 'adds eml data' do
68
+ describe "#add_eml_data" do
69
+ it "adds eml data" do
60
70
  gen.add_eml_xml(EML_DATA)
61
- eml = File.read(File.join(gen.path, 'eml.xml'))
62
- expect(eml).to match /jdoe@example.com/
71
+ eml = File.read(File.join(gen.path, "eml.xml")).strip
72
+ eml.gsub!(%r{(<pubDate>).*?(</pubDate>)}, '\12013-12-30 14:45:33 -0500\2')
73
+ eml.gsub!(/(packageId=").*?"/, '\11234/2013-12-30::19:45:33"')
74
+
75
+ eml_from_file = File.read(
76
+ File.expand_path("../files/generator_eml.xml", __dir__)
77
+ ).strip
78
+ expect(eml.strip).to eq eml_from_file.strip
63
79
  end
64
80
  end
65
81
 
66
- describe '#path' do
67
- it 'returns temporary path for assembling DwCA' do
68
- expect(gen.path).to match /dwc_\d+$/
82
+ describe "#path" do
83
+ it "returns temporary path for assembling DwCA" do
84
+ expect(gen.path).to match(/dwc_\d+$/)
69
85
  end
70
86
  end
71
87
 
72
- describe '#files' do
73
- it 'returns created files' do
74
- gen.add_core(CORE_DATA.dup, 'core.csv', true)
75
- gen.add_extension(EXTENSION_DATA.dup,
76
- 'vern.csv',
77
- true,
78
- 'http://rs.gbif.org/terms/1.0/VernacularName')
88
+ describe "#files" do
89
+ before(:example) { generate_dwca(gen) }
79
90
 
80
- gen.add_meta_xml
81
- expect(gen.files).to match_array ['core.csv', 'meta.xml', 'vern.csv']
91
+ it "returns created files" do
92
+ expect(gen.files).
93
+ to match_array ["core.csv", "eml.xml", "meta.xml", "vern.csv"]
82
94
  end
83
95
  end
84
96
 
85
- describe '#pack' do
86
- it 'creates final DwCA file' do
87
- FileUtils.rm dwc_path if File.exists?(dwc_path)
88
- gen.add_core(CORE_DATA.dup, 'core.csv', true)
89
- gen.add_extension(EXTENSION_DATA.dup,
90
- 'vern.csv',
91
- true,
92
- 'http://rs.gbif.org/terms/1.0/VernacularName')
97
+ describe "#pack" do
98
+ before(:example) do
99
+ FileUtils.rm dwc_path if File.exist?(dwc_path)
100
+ generate_dwca(gen)
101
+ end
93
102
 
94
- gen.add_meta_xml
95
- gen.add_eml_xml(EML_DATA)
103
+ it "creates final DwCA file" do
96
104
  gen.pack
97
- expect(File.exists?(dwc_path)).to be_true
105
+ expect(File.exist?(dwc_path)).to be true
98
106
  end
99
107
  end
100
108
 
101
- describe '#clean' do
102
- it 'removes temporary directory for DwCA' do
103
- gen.add_eml_xml(EML_DATA)
104
- expect(File.exists?(gen.path)).to be true
109
+ describe "#clean" do
110
+ before(:example) { gen.add_eml_xml(EML_DATA) }
111
+
112
+ it "removes temporary directory for DwCA" do
113
+ expect(File.exist?(gen.path)).to be true
105
114
  gen.clean
106
- expect(File.exists?(gen.path)).to be false
115
+ expect(File.exist?(gen.path)).to be false
107
116
  end
108
117
  end
109
118
 
110
- describe '#eml_xml_data' do
111
- it 'returns current eml data' do
119
+ describe "#eml_xml_data" do
120
+ it "returns current eml data" do
112
121
  expect(gen.eml_xml_data).to be_kind_of Hash
113
122
  end
114
123
  end
115
-
116
124
  end
@@ -1,34 +1,32 @@
1
- require_relative '../spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe DarwinCore::GnubTaxon do
4
4
  subject(:dwca) { DarwinCore.new(file_path) }
5
5
  subject(:normalizer) { DarwinCore::ClassificationNormalizer.new(dwca) }
6
- let(:file_dir) { File.expand_path('../../files', __FILE__) }
6
+ let(:file_dir) { File.expand_path("../files", __dir__) }
7
7
  let(:file_path) { File.join(file_dir, file_name) }
8
- let(:file_name) { 'gnub.tar.gz' }
8
+ let(:file_name) { "gnub.tar.gz" }
9
9
 
10
- it 'should get uuids from GNUB' do
10
+ it "should get uuids from GNUB" do
11
11
  normalizer.normalize
12
- tn = normalizer.normalized_data['9c399f90-cfb8-5a7f-9a21-18285a473488']
12
+ tn = normalizer.normalized_data["9c399f90-cfb8-5a7f-9a21-18285a473488"]
13
13
  expect(tn).to be_kind_of DarwinCore::GnubTaxon
14
14
  expect(tn).to be_kind_of DarwinCore::TaxonNormalized
15
- expect(tn.uuid).to eq '8faa91f6-663f-4cfe-b785-0ab4e9415a51'
16
- expect(tn.uuid_path).to eq [
17
- '9a9f9eeb-d5f9-4ff6-b6cb-a5ad345e33c3',
18
- 'bf4c91c0-3d1f-44c7-9d3b-249382182a26',
19
- '8faa91f6-663f-4cfe-b785-0ab4e9415a51']
20
-
15
+ expect(tn.uuid).to eq "8faa91f6-663f-4cfe-b785-0ab4e9415a51"
16
+ expect(tn.uuid_path).to eq %w[
17
+ 9a9f9eeb-d5f9-4ff6-b6cb-a5ad345e33c3
18
+ bf4c91c0-3d1f-44c7-9d3b-249382182a26
19
+ 8faa91f6-663f-4cfe-b785-0ab4e9415a51
20
+ ]
21
21
  end
22
22
 
23
-
24
- context 'not a gnub data' do
25
- let(:file_name) { 'data.tar.gz' }
26
- it 'should not be of GnubTaxon type' do
23
+ context "not a gnub data" do
24
+ let(:file_name) { "data.tar.gz" }
25
+ it "should not be of GnubTaxon type" do
27
26
  normalizer.normalize
28
- tn = normalizer.normalized_data['leptogastrinae:tid:42']
27
+ tn = normalizer.normalized_data["leptogastrinae:tid:42"]
29
28
  expect(tn).to be_kind_of DarwinCore::TaxonNormalized
30
29
  expect(tn).not_to be_kind_of DarwinCore::GnubTaxon
31
30
  end
32
31
  end
33
-
34
32
  end
@@ -1,80 +1,89 @@
1
- require_relative '../spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe DarwinCore::Metadata do
4
- subject(:dwca) { DarwinCore.new(file_path) }
5
4
  subject(:eml) { DarwinCore::Metadata.new(dwca.archive) }
6
- let(:file_path) { File.join(File.expand_path('../../files', __FILE__),
7
- file_name) }
8
- let(:file_name) { 'data.tar.gz' }
9
-
10
- describe '.new' do
11
- it 'initializes' do
5
+ let(:dwca) { DarwinCore.new(file_path) }
6
+ let(:file_path) do
7
+ File.join(File.expand_path("../files", __dir__), file_name)
8
+ end
9
+ let(:file_name) { "data.tar.gz" }
10
+
11
+ describe ".new" do
12
+ it "initializes" do
12
13
  expect(eml).to be_kind_of DarwinCore::Metadata
13
14
  end
14
15
  end
15
16
 
16
- describe '#data' do
17
- it 'returns hash of metadata' do
17
+ describe "#data" do
18
+ it "returns hash of metadata" do
18
19
  expect(eml.data).to be_kind_of Hash
19
20
  end
20
21
  end
21
22
 
22
- describe '#id' do
23
- it 'returns id of the archive if it exists' do
24
- expect(eml.id).to eq 'leptogastrinae:version:2.5'
23
+ describe "#id" do
24
+ it "returns id of the archive if it exists" do
25
+ expect(eml.id).to eq "leptogastrinae:version:2.5"
25
26
  end
26
27
  end
27
28
 
28
- describe '#package_id' do
29
- context 'no package id is given' do
30
- it 'returns id of the DwCA file if exists' do
29
+ describe "#package_id" do
30
+ context "no package id is given" do
31
+ before(:example) do
32
+ @attributes = eml.data[:eml].delete(:attributes)
33
+ end
34
+
35
+ after(:example) do
36
+ eml.data[:eml][:attributes] = @attributes
37
+ end
38
+
39
+ it "returns id of the DwCA file if exists" do
40
+ expect { eml.data[:eml][:attributes][:packageId] }.
41
+ to raise_exception NoMethodError
31
42
  expect(eml.package_id).to be_nil
32
43
  end
33
44
  end
34
45
  end
35
46
 
36
- describe '#title' do
37
- it 'returns name of the archive' do
47
+ describe "#title" do
48
+ it "returns name of the archive" do
38
49
  expect(eml.title).
39
- to eq 'Leptogastrinae (Diptera: Asilidae) Classification'
50
+ to eq "Leptogastrinae (Diptera: Asilidae) Classification"
40
51
  end
41
52
  end
42
53
 
43
- describe '#authors' do
44
- it 'returns authors of the archive' do
54
+ describe "#authors" do
55
+ it "returns authors of the archive" do
45
56
  expect(eml.authors).
46
57
  to eq [
47
- {:first_name=>"Keith",
48
- :last_name=>"Bayless",
49
- :email=>"keith.bayless@gmail.com"},
50
- {:first_name=>"Torsten",
51
- :last_name=>"Dikow",
52
- :email=>"dshorthouse@eol.org"}]
58
+ { first_name: "Keith",
59
+ last_name: "Bayless",
60
+ email: "keith.bayless@gmail.com" },
61
+ { first_name: "Torsten",
62
+ last_name: "Dikow",
63
+ email: "dshorthouse@eol.org" }
64
+ ]
53
65
  end
54
66
 
55
- describe '#abstract' do
56
- it 'returns abstract of an article' do
67
+ describe "#abstract" do
68
+ it "returns abstract of an article" do
57
69
  expect(eml.abstract).
58
- to eq 'These are all the names in the Leptogastrinae classification.'
70
+ to eq "These are all the names in the Leptogastrinae classification."
59
71
  end
60
72
  end
61
73
 
62
- describe '#citation' do
63
- it 'returns citation of the archive' do
74
+ describe "#citation" do
75
+ it "returns citation of the archive" do
64
76
  expect(eml.citation).
65
- to eq 'Dikow, Torsten. 2010. The Leptogastrinae classification.'
77
+ to eq "Dikow, Torsten. 2010. The Leptogastrinae classification."
66
78
  end
67
79
  end
68
80
 
69
- describe '#url' do
70
- it 'returns url to the archive' do
71
- expect(eml.url).to eq 'http://leptogastrinae.lifedesks.org'\
72
- '/files/leptogastrinae/'\
73
- 'classification_export/shared/'\
74
- 'leptogastrinae.tar.gz'
81
+ describe "#url" do
82
+ it "returns url to the archive" do
83
+ expect(eml.url).
84
+ to eq "http://leptogastrinae.lifedesks.org/files/leptogastrinae/"\
85
+ "classification_export/shared/leptogastrinae.tar.gz"
75
86
  end
76
87
  end
77
-
78
88
  end
79
89
  end
80
-
@@ -1,99 +1,97 @@
1
- require_relative '../spec_helper'
2
- # encoding: utf-8
1
+ # frozen_string_literal: true
3
2
 
4
3
  describe DarwinCore::TaxonNormalized do
5
4
  subject(:dwca) { DarwinCore.new(file_path) }
6
5
  subject(:normalizer) { DarwinCore::ClassificationNormalizer.new(dwca) }
7
- let(:file_dir) { File.expand_path('../../files', __FILE__) }
6
+ let(:file_dir) { File.expand_path("../files", __dir__) }
8
7
 
9
- context 'typical case' do
10
- let(:file_path) { File.join(file_dir, 'data.tar.gz') }
8
+ context "typical case" do
9
+ let(:file_path) { File.join(file_dir, "data.tar.gz") }
11
10
  let(:normalized) { normalizer.normalize }
12
- let(:tn) { normalized['leptogastrinae:tid:2681'] }
11
+ let(:tn) { normalized["leptogastrinae:tid:2681"] }
13
12
 
14
- it 'has TaxonNormalized type' do
13
+ it "has TaxonNormalized type" do
15
14
  expect(tn).to be_kind_of DarwinCore::TaxonNormalized
16
15
  end
17
16
 
18
- describe '#id' do
19
- it 'returns taxon_id' do
20
- expect(tn.id).to eq 'leptogastrinae:tid:2681'
17
+ describe "#id" do
18
+ it "returns taxon_id" do
19
+ expect(tn.id).to eq "leptogastrinae:tid:2681"
21
20
  end
22
21
  end
23
22
 
24
- describe '#local_id' do
25
- it 'returns local id' do
26
- expect(tn.id).to eq 'leptogastrinae:tid:2681'
23
+ describe "#local_id" do
24
+ it "returns local id" do
25
+ expect(tn.id).to eq "leptogastrinae:tid:2681"
27
26
  end
28
27
  end
29
28
 
30
- describe '#global_id' do
31
- it 'returns global id' do
32
- expect(tn.global_id).to eq '843ff0df-4bcd-4aad-ba94-643f8695a292'
29
+ describe "#global_id" do
30
+ it "returns global id" do
31
+ expect(tn.global_id).to eq "843ff0df-4bcd-4aad-ba94-643f8695a292"
33
32
  end
34
33
  end
35
34
 
36
- describe '#source' do
37
- it 'returns url to the data' do
35
+ describe "#source" do
36
+ it "returns url to the data" do
38
37
  expect(tn.source).
39
- to eq 'http://leptogastrinae.lifedesks.org/pages/2681'
38
+ to eq "http://leptogastrinae.lifedesks.org/pages/2681"
40
39
  end
41
- end
40
+ end
42
41
 
43
- describe '#parent_id' do
44
- it 'returns ancestor\'s id' do
45
- expect(tn.parent_id).to eq 'leptogastrinae:tid:2584'
42
+ describe "#parent_id" do
43
+ it "returns ancestor's id" do
44
+ expect(tn.parent_id).to eq "leptogastrinae:tid:2584"
46
45
  end
47
46
  end
48
-
49
- describe '#classification_path_id' do
50
- it 'returns an array' do
47
+
48
+ describe "#classification_path_id" do
49
+ it "returns an array" do
51
50
  expect(tn.classification_path_id).to be_kind_of Array
52
51
  end
53
52
 
54
- it 'returns ids of classification path elements' do
53
+ it "returns ids of classification path elements" do
55
54
  expect(tn.classification_path_id).
56
- to eq ['leptogastrinae:tid:42',
57
- 'leptogastrinae:tid:2045',
58
- 'leptogastrinae:tid:2584',
59
- 'leptogastrinae:tid:2681']
55
+ to eq ["leptogastrinae:tid:42",
56
+ "leptogastrinae:tid:2045",
57
+ "leptogastrinae:tid:2584",
58
+ "leptogastrinae:tid:2681"]
60
59
  end
61
60
  end
62
61
 
63
- describe '#classification_path' do
62
+ describe "#classification_path" do
64
63
  let(:cp) { tn.classification_path }
65
- it 'returns array of name strings of the classification path' do
64
+ it "returns array of name strings of the classification path" do
66
65
  expect(cp).to be_kind_of Array
67
- expect(cp).to eq ["Leptogastrinae",
68
- "Leptogastrini",
69
- "Leptogaster",
70
- "Leptogaster flavipes"]
66
+ expect(cp).to eq ["Leptogastrinae",
67
+ "Leptogastrini",
68
+ "Leptogaster",
69
+ "Leptogaster flavipes"]
71
70
  end
72
71
  end
73
72
 
74
- describe '#linnean_classification_path' do
75
- it 'returns empty array for parent/child based classification' do
73
+ describe "#linnean_classification_path" do
74
+ it "returns empty array for parent/child based classification" do
76
75
  expect(tn.linnean_classification_path).to be_kind_of Array
77
76
  expect(tn.linnean_classification_path).to be_empty
78
77
  end
79
78
  end
80
79
 
81
- describe '#current_name' do
82
- it 'returns name marked as currently valid for the taxon' do
83
- expect(tn.current_name).to eq 'Leptogaster flavipes Loew, 1862'
80
+ describe "#current_name" do
81
+ it "returns name marked as currently valid for the taxon" do
82
+ expect(tn.current_name).to eq "Leptogaster flavipes Loew, 1862"
84
83
  end
85
84
  end
86
-
87
- describe '#current_name_canonical' do
88
- it 'returns canonical form of valid name' do
89
- expect(tn.current_name_canonical).to eq 'Leptogaster flavipes'
85
+
86
+ describe "#current_name_canonical" do
87
+ it "returns canonical form of valid name" do
88
+ expect(tn.current_name_canonical).to eq "Leptogaster flavipes"
90
89
  end
91
90
  end
92
91
 
93
- describe '#synonyms' do
94
- context 'synonyms not found' do
95
-
96
- it 'returns empty array' do
92
+ describe "#synonyms" do
93
+ context "synonyms not found" do
94
+ it "returns empty array" do
97
95
  expect(tn.synonyms).to be_kind_of Array
98
96
  synonym = tn.synonyms[0]
99
97
  expect(synonym).to be_kind_of DarwinCore::SynonymNormalized
@@ -101,26 +99,26 @@ describe DarwinCore::TaxonNormalized do
101
99
  end
102
100
  end
103
101
 
104
- context 'synonyms found' do
105
- let(:tn) { normalized['leptogastrinae:tid:2858'] }
106
- it 'returns array of synonyms' do
102
+ context "synonyms found" do
103
+ let(:tn) { normalized["leptogastrinae:tid:2858"] }
104
+ it "returns array of synonyms" do
107
105
  expect(tn.synonyms).to be_kind_of Array
108
106
  expect(tn.synonyms).to be_empty
109
107
  end
110
108
  end
111
109
  end
112
110
 
113
- describe '#vernacular_names' do
114
- context 'vernacular names not found' do
115
- it 'returns empty array' do
111
+ describe "#vernacular_names" do
112
+ context "vernacular names not found" do
113
+ it "returns empty array" do
116
114
  expect(tn.vernacular_names).to be_kind_of Array
117
115
  expect(tn.vernacular_names).to be_empty
118
116
  end
119
117
  end
120
118
 
121
- context 'vernacular names found' do
122
- let(:tn) { normalized['leptogastrinae:tid:42'] }
123
- it 'returns array with vernacular name structure' do
119
+ context "vernacular names found" do
120
+ let(:tn) { normalized["leptogastrinae:tid:42"] }
121
+ it "returns array with vernacular name structure" do
124
122
  expect(tn.vernacular_names).to be_kind_of Array
125
123
  vn = tn.vernacular_names[0]
126
124
  expect(vn).to be_kind_of DarwinCore::VernacularNormalized
@@ -129,17 +127,16 @@ describe DarwinCore::TaxonNormalized do
129
127
  end
130
128
  end
131
129
 
132
- describe '#rank' do
133
- it 'returns rank of the taxon' do
134
- expect(tn.rank).to eq 'species'
130
+ describe "#rank" do
131
+ it "returns rank of the taxon" do
132
+ expect(tn.rank).to eq "species"
135
133
  end
136
134
  end
137
135
 
138
- describe '#status' do
139
- it 'returns status of taxon' do
136
+ describe "#status" do
137
+ it "returns status of taxon" do
140
138
  expect(tn.status).to be_nil
141
139
  end
142
140
  end
143
141
  end
144
-
145
142
  end