Permalink
Browse files

refactored some tests

  • Loading branch information...
1 parent 3ac8d78 commit 4207575427cb09debb376adb0bf2ee5a690f5556 @dimus dimus committed Dec 30, 2013
View
@@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'bundler', '~> 1.3'
gem.add_development_dependency 'rake', '~> 10.1'
gem.add_development_dependency 'rspec', '~> 2.14'
+ gem.add_development_dependency 'webmock', '~> 1.13'
gem.add_development_dependency 'rr', '~> 1.1'
gem.add_development_dependency 'debugger', '~> 1.6'
end
View
@@ -1,9 +1,13 @@
require 'spec_helper'
describe Biodiversity do
- it 'should have version' do
- version = Biodiversity::VERSION
- version.should =~ /^\d+\.\d+\.\d+/
- version.should == Biodiversity.version
+ describe '.version' do
+ it 'returns version' do
+ expect(subject.version).to match /^\d+\.\d+\.\d+/
+ end
+
+ it 'is the same as Biodiversity::Version constant' do
+ expect(subject.version).to eq Biodiversity::VERSION
+ end
end
end
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,55 @@
+Rana aurora Baird and Girard, 1852; H.B. Shaffer et al., 2004 <---- WRONG CANONICAL FORM!!!!!!!!
+
+Gemmula cf. cosmoi NP-2008 <--- WRONG CANONICAL FORM
+Eupithecia cf. E. maestosa
+Eupithecia cf. maestosa
+Aleiodes Tetrasphaeropyx chumashanus => Aleiodes [subgenus] chumashanus
+
+Cucurbita pepo subsp. ovifera x subsp. fraterna
+
+Döringina Ihering 1929 (synonym) Dzzringina
+Doringina Ihering, 1929 (synonym) Döringina
+
+Lacanobia nr. subjuncta Bold:Aab, 0925 Lacanobia nr
+Lacanobia sp. nr. subjuncta Bold:Aab, 0925 Lacanobia sp
+
+Agropyron pectiniforme var. karabaljikji ined.? Agropyron pectiniforme
+Shaanxilithes Xing, Yue & Zhang, 1984 Shaanxilithes ing
+Parapandorina Xue, Tang, Yu & Zhou 1995 Parapandorina ue
+
+Potamogeton iilinoensis var. ventanicola (Hicken) Horn af Rantzien Potamogeton iilinoensis var. ventanicola af
+Rhododendron weyrichii Maxim. f. albiflorum T.Yamaz. Rhododendron
+
+Polypodium pectinatum L. f. typica Rosenst. Polypodium
+Polypodium lineare C.Chr. f. caudatoattenuatum Takeda Polypodium
+
+
+Rosa gallica × tomentosa var. eglandulosa R.Keller Rosa gallica
+Rosa gallica × afzeliana subsp. vosagiaca forma subcomplicata R.Keller Rosa gallica
+
+Salmonella sp. (ser.) brancaster Macdonald, Sivell, Emms and Taylor 1948
+
+Stanhopea tigrina Bateman ex Lindl. x S. ecornuta Lem.
+
+
+Junellia o'donelli Moldenke, 1946
+
+119052670 | Human rhinovirus A11 |
+
+Rubus idaeus monst. obtusifolius (Willd.) Focke | Rubus idaeus
+
+Kerana var. cameroni |Kerana var
+
+A. alba
+A.alba
+
+Bangalaia viridis sbsp. distinctemaculata Lepesme & Breuning, 1956
+
+Clostridium sp. enrichment culture clone M4C16
+
+
+000913765 Rubus x gracilidens Sudre
+ Rubus gracilidens | 1
+
+
+Salix myrtilloides x starkeana ssp. starkeana
View
@@ -1,9 +1,17 @@
require_relative '../spec_helper'
describe LsidResolver do
- it 'should return RFD document from lsid' do
- lsid = 'urn:lsid:ubio.org:classificationbank:2232671'
- stub(LsidResolver).resolve(lsid) {''}
- LsidResolver.resolve(lsid).class.should == String
+ describe '.resolve' do
+ let(:lsid) { 'urn:lsid:ubio.org:classificationbank:2232671' }
+
+ it 'resolves lsid using tdwg service' do
+ stub_request(:get,
+ %r|#{Biodiversity::LSID_RESOLVER_URL + lsid}|).to_return do
+ { body: File.read(File.expand_path('../../files/lsid.xml', __FILE__)) }
+ end
+ expect(LsidResolver.resolve lsid).
+ to match %r|<dc:title>Pternistis Wagler 1832</dc:title>|
+ end
end
+
end
@@ -6,7 +6,7 @@
set_parser(ScientificNameCanonicalParser.new)
end
- it 'should parse names with valid name part and unparseable rest' do
+ it 'parses names with valid name part and unparseable rest' do
[
['Morea ssjjlajajaj324$33 234243242','Morea',
[{:uninomial=>{:string=>"Morea"}}], {0=>["uninomial", 5]}],
@@ -26,11 +26,11 @@
[{:genus=>{:string=>"Verpericola"}, :species=>{:string=>"megasoma"}}],
{0=>["genus", 11], 12=>["species", 20]}]
].each do |n|
- parse(n[0]).should_not be_nil
- value(n[0]).should == n[1]
- details(n[0]).should == n[2]
- pos(n[0]).should == n[3]
- parse(n[0]).hybrid.should be_false
+ expect(parse(n[0])).not_to be_nil
+ expect(value(n[0])).to eq n[1]
+ expect(details(n[0])).to eq n[2]
+ expect(pos(n[0])).to eq n[3]
+ expect(parse(n[0]).hybrid).to be_false
end
end
View
@@ -2,6 +2,7 @@
require 'treetop'
require 'json'
require 'biodiversity'
+require 'webmock/rspec'
RSpec.configure do |c|
@@ -67,8 +68,7 @@ def debug(input)
end
def read_test_file
- f = open(File.expand_path(File.join(File.dirname(__FILE__),
- 'parser/test_data.txt')))
+ f = open(File.expand_path('../files/test_data.txt', __FILE__))
f.each do |line|
name, jsn = line.split("|")
if line.match(/^\s*#/) == nil && name && jsn

0 comments on commit 4207575

Please sign in to comment.