spec/parser/scientific_name_clean.spec.rb in dimus-biodiversity-0.5.1 vs spec/parser/scientific_name_clean.spec.rb in dimus-biodiversity-0.5.2
- old
+ new
@@ -1,39 +1,15 @@
# encoding: UTF-8
dir = File.dirname("__FILE__")
-require 'rubygems'
-require 'spec'
-require 'yaml'
-require 'treetop'
+require File.expand_path(dir + '../../spec/parser/spec_helper')
-Treetop.load(File.expand_path(dir + '../../lib/biodiversity/parser/scientific_name_clean'))
describe ScientificNameClean do
before(:all) do
- @parser = ScientificNameCleanParser.new
+ set_parser(ScientificNameCleanParser.new)
end
- def parse(input)
- @parser.parse(input)
- end
-
- def value(input)
- parse(input).value
- end
-
- def canonical(input)
- parse(input).canonical
- end
-
- def details(input)
- parse(input).details
- end
-
- def pos(input)
- parse(input).pos
- end
-
it 'should parse uninomial' do
sn = 'Pseudocercospora'
parse(sn).should_not be_nil
value(sn).should == 'Pseudocercospora'
canonical(sn).should == 'Pseudocercospora'
@@ -310,11 +286,11 @@
sn = "Gastrosericus eremorum van Beaumont 1955"
canonical(sn).should == 'Gastrosericus eremorum'
sn = "Gastrosericus eremorum von Beaumont 1955"
canonical(sn).should == 'Gastrosericus eremorum'
sn = "Cypraeovula (Luponia) amphithales perdentata"
- canonical(sn).should == 'Cypraeovula amphithales perdentata'
+ canonical(sn).should == 'Cypraeovula Luponia amphithales perdentata'
details(sn).should == {:genus=>{:epitheton=>"Cypraeovula"}, :subgenus=>{:epitheton=>"Luponia"}, :species=>{:epitheton=>"amphithales"}, :infraspecies=>{:epitheton=>"perdentata", :rank=>"n/a"}}
sn = "Polyrhachis orsyllus nat musculus Forel 1901"
canonical(sn).should == "Polyrhachis orsyllus musculus"
sn = 'Latrodectus 13-guttatus Thorell, 1875'
canonical(sn).should == 'Latrodectus 13-guttatus'
@@ -488,7 +464,35 @@
parse("Érematosphaeria phaespora").should be_nil
parse("Trematosphaeria phaeáapora").should be_nil
parse("Trematоsphaeria phaeáapora").should be_nil #cyrillic o
end
+ it "should parse new stuff" do
+ sn = 'Nesticus quelpartensis Paik & Namkung, in Paik, Yaginuma & Namkung, 1969'
+ details(sn).should == {:genus=>{:epitheton=>"Nesticus"}, :species=>{:epitheton=>"quelpartensis", :authorship=>"Paik & Namkung, in Paik, Yaginuma & Namkung, 1969", :basionymAuthorTeam=>{:authorTeam=>"Paik & Namkung", :author=>["Paik", "Namkung"], :exAuthorTeam=>{:authorTeam=>"Paik, Yaginuma & Namkung", :author=>["Paik", "Yaginuma", "Namkung"], :year=>"1969"}}}}
+ parse('Dipoena yoshidai Ono, in Ono et al., 1991').should_not be_nil
+ sn = 'Choriozopella trägårdhi Lawrence, 1947'
+ details(sn).should == {:genus=>{:epitheton=>"Choriozopella"}, :species=>{:epitheton=>"trägårdhi", :authorship=>"Lawrence, 1947", :basionymAuthorTeam=>{:authorTeam=>"Lawrence", :author=>["Lawrence"], :year=>"1947"}}}
+ sn = 'Latrodectus mactans bishopi Kaston, 1938'
+ details(sn).should == {:genus=>{:epitheton=>"Latrodectus"}, :species=>{:epitheton=>"mactans"}, :infraspecies=>{:epitheton=>"bishopi", :rank=>"n/a", :authorship=>"Kaston, 1938", :basionymAuthorTeam=>{:authorTeam=>"Kaston", :author=>["Kaston"], :year=>"1938"}}}
+ sn = 'Diplocephalus aff. procerus Thaler, 1972'
+ details(sn).should == {:genus=>{:epitheton=>"Diplocephalus"}, :species=>{:epitheton=>"procerus", :authorship=>"Thaler, 1972", :basionymAuthorTeam=>{:authorTeam=>"Thaler", :author=>["Thaler"], :year=>"1972"}}}
+ sn = 'Dyarcyops birói Kulczynski, 1908'
+ details(sn).should == {:genus=>{:epitheton=>"Dyarcyops"}, :species=>{:epitheton=>"birói", :authorship=>"Kulczynski, 1908", :basionymAuthorTeam=>{:authorTeam=>"Kulczynski", :author=>["Kulczynski"], :year=>"1908"}}}
+ sn = 'Sparassus françoisi Simon, 1898'
+ details(sn).should == {:genus=>{:epitheton=>"Sparassus"}, :species=>{:epitheton=>"françoisi", :authorship=>"Simon, 1898", :basionymAuthorTeam=>{:authorTeam=>"Simon", :author=>["Simon"], :year=>"1898"}}}
+ sn = 'Thiobacillus x Parker and Prisk 1953' #have to figure out black lists for this one
+ sn = 'Bacille de Plaut, Kritchevsky and Séguin 1921'
+ details(sn).should == {:uninomial=>{:epitheton=>"Bacille", :authorship=>"de Plaut, Kritchevsky and Séguin 1921", :basionymAuthorTeam=>{:authorTeam=>"de Plaut, Kritchevsky and Séguin", :author=>["de Plaut", "Kritchevsky", "Séguin"], :year=>"1921"}}}
+ sn = 'Araneus van bruysseli Petrunkevitch, 1911'
+ details(sn).should == {:genus=>{:epitheton=>"Araneus"}, :species=>{:epitheton=>"van"}, :infraspecies=>{:epitheton=>"bruysseli", :rank=>"n/a", :authorship=>"Petrunkevitch, 1911", :basionymAuthorTeam=>{:authorTeam=>"Petrunkevitch", :author=>["Petrunkevitch"], :year=>"1911"}}}
+ sn = 'Sapromyces laidlawi ab Sabin 1941'
+ details(sn).should == {:genus=>{:epitheton=>"Sapromyces"}, :species=>{:epitheton=>"laidlawi", :authorship=>"ab Sabin 1941", :basionymAuthorTeam=>{:authorTeam=>"ab Sabin", :author=>["ab Sabin"], :year=>"1941"}}}
+ sn = 'Nocardia rugosa di Marco and Spalla 1957'
+ details(sn).should == {:genus=>{:epitheton=>"Nocardia"}, :species=>{:epitheton=>"rugosa", :authorship=>"di Marco and Spalla 1957", :basionymAuthorTeam=>{:authorTeam=>"di Marco and Spalla", :author=>["di Marco", "Spalla"], :year=>"1957"}}}
+ sn = 'Flexibacter elegans Lewin 1969 non Soriano 1945'
+ details(sn).should == {:genus=>{:epitheton=>"Flexibacter"}, :species=>{:epitheton=>"elegans", :authorship=>"Lewin 1969 non Soriano 1945", :basionymAuthorTeam=>{:authorTeam=>"Lewin", :author=>["Lewin"], :year=>"1969"}}}
+ sn = 'Flexibacter elegans Soriano 1945, non Lewin 1969'
+ details(sn).should == {:genus=>{:epitheton=>"Flexibacter"}, :species=>{:epitheton=>"elegans", :authorship=>"Soriano 1945, non Lewin 1969", :basionymAuthorTeam=>{:authorTeam=>"Soriano", :author=>["Soriano"], :year=>"1945"}}}
+ end
end
\ No newline at end of file