spec/name-spotter_spec.rb in name-spotter-0.2.1 vs spec/name-spotter_spec.rb in name-spotter-0.2.2

- old
+ new

@@ -8,10 +8,25 @@ @neti = NameSpotter.new(neti_neti) @tf = NameSpotter.new(taxon_finder) @clients = [@neti, @tf] end + it "should find if a text is in english" do + eng = open(File.join(File.dirname(__FILE__), 'files', 'english.txt'), 'r:utf-8').read + eng2 = open(File.join(File.dirname(__FILE__), 'files', 'english.txt'), 'r:utf-8').read + eng3 = open(File.join(File.dirname(__FILE__), 'files', 'journalofentomol13pomo_0018.txt'), 'r:utf-8').read + eng3 = open(File.join(File.dirname(__FILE__), 'files', 'journalofentomol13pomo_0063.txt'), 'r:utf-8').read + + not_eng = open(File.join(File.dirname(__FILE__), 'files', 'not_english.txt'), 'r:utf-8').read + 100.times do + NameSpotter.english?(eng).should be_true + NameSpotter.english?(eng2).should be_true + NameSpotter.english?(eng3).should be_false + NameSpotter.english?(not_eng).should be_false + end + end + it "should exist" do @neti.is_a?(NameSpotter).should be_true @tf.is_a?(NameSpotter).should be_true end @@ -60,10 +75,12 @@ res = @tf.find(text)[:names].map { |n| n[:scientificName] } res.should == ['Xysticus canadensis', 'Pardosa moesta', 'X[ysticus] canadensis'] end it "should get back correct names using offsets in utf-8 based text" do - text = "A text with multibyte characters नेति नेति: 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" + # this test depends on netineti tornado server, not on namespotter itself. Go and fix that! + # the issue and the fix: https://github.com/mbl-cli/NetiNeti/pull/1 + text = "\r\r\n>':¥/. \r\nA text with multibyte characters नेति नेति: 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] res.map do |name| verbatim = name[:verbatim] found_name = text[name[:offsetStart]..name[:offsetEnd]] found_name.should == verbatim