Sha256: 21f883cc8be91e1a59c2422328060609d731127370371d9650b517645701e00d
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "NameSpotter" do before(:all) do neti_neti = NameSpotter::NetiNetiClient.new() taxon_finder = NameSpotter::TaxonFinderClient.new() @neti = NameSpotter.new(neti_neti) @tf = NameSpotter.new(taxon_finder) @clients = [@neti, @tf] end it "should exist" do @neti.is_a?(NameSpotter).should be_true @tf.is_a?(NameSpotter).should be_true end it "should use ruby as default format" do @clients.each do |c| c.find(nil).should == {names: []} end end it "should return empty result if input is empty" do @clients.each do |c| c.find(nil, 'json').should == "{\"names\":[]}" c.find(nil, "xml").should == "<?xml version=\"1.0\"?>\n<names/>\n" c.find('', 'json').should == "{\"names\":[]}" c.find('', "xml").should == "<?xml version=\"1.0\"?>\n<names/>\n" end end it "should return empty result if no names are found" do text = "one two three, no scientific names" @clients.each do |c| c.find(text, "json").should == "{\"names\":[]}" c.find(text, "xml").should == "<?xml version=\"1.0\"?>\n<names/>\n" end end it "should be able to find scientific names in text" do text = "Some text that has Betula\n alba and Mus musculus and \neven B. alba and even M. mus-\nculus. Also it has name unknown before: Varanus bitatawa species" res = @neti.find(text)[:names].map { |n| n[:scientificName] } res.should == ["Betula alba", "Mus musculus", "B. alba", "Varanus bitatawa"] res = @tf.find(text)[:names].map { |n| n[:scientificName] } res.should == ["Betula alba", "Mus musculus", "B[etula] alba", "Varanus"] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
name-spotter-0.0.3 | spec/name-spotter_spec.rb |
name-spotter-0.0.2 | spec/name-spotter_spec.rb |