spec/ref2bibtex_spec.rb in ref2bibtex-0.2.3 vs spec/ref2bibtex_spec.rb in ref2bibtex-0.3.0

- old
+ new

@@ -26,11 +26,11 @@ end end context '.get_doi' do specify 'takes a full citation and returns a string' do - expect(Ref2bibtex.get_doi(CITATIONS[:first])).to eq('http://dx.doi.org/10.3897/zookeys.20.205') + expect(Ref2bibtex.get_doi(CITATIONS[:first])).to eq('https://doi.org/10.3897/zookeys.20.205') end specify 'a citation that can not be resolved returns false' do expect(Ref2bibtex.get_doi(CITATIONS[:eighth])).to eq(false) end @@ -39,11 +39,11 @@ expect(Ref2bibtex.get_doi('asfas')).to eq(false) end end context '.get_bibtex' do - let(:response) { Ref2bibtex.get_bibtex('http://dx.doi.org/10.3897/zookeys.20.205')} + let(:response) { Ref2bibtex.get_bibtex('https://dx.doi.org/10.3897/zookeys.20.205')} specify 'takes a full citation and returns bibtex' do expect(response).to match(/author\s=/) expect(response).to match(/title\s=/) expect(response).to match(/year\s=\s2009/) end @@ -69,22 +69,24 @@ end context 'interpretation' do before(:all) { @scores = CITATIONS.keys.inject({}) { |hsh, c| + sleep 0.5 # throttle timing a little hsh.merge!( c => Ref2bibtex.get_score(CITATIONS[c]) ) } + @scores } specify 'mangled text is worse than good text' do expect( @scores[:second] > @scores[:seventh] ).to be_truthy end context 'default @@cutoff is reasonable and slightly conservative' do - let(:good_citations) { [:first, :second, :third, :fourth, :sixth] } + let(:good_citations) { [:first, :second, :third] } # remainders have moved to unresolvable let(:bad_citations) { CITATIONS.keys - good_citations } specify 'for good citations' do good_citations.each do |c| expect(@scores[c]).to be > Ref2bibtex.cutoff @@ -92,10 +94,11 @@ end specify 'for bad citations' do bad_citations.each do |c| if @scores[c] + expect(@scores[c]).to be < Ref2bibtex.cutoff end end end end @@ -109,10 +112,11 @@ specify 'can be used to reject good matches' do Ref2bibtex.cutoff = 1000 expect(Ref2bibtex.get_doi(CITATIONS[:first])).to eq(false) end - specify 'can be used to accept bad matches' do + # Cutoff is more finely tuned to exclude bad matches now. + xspecify 'can be used to accept bad matches' do Ref2bibtex.cutoff = 1 expect(Ref2bibtex.get_doi(CITATIONS[:fifth])).to be_truthy end end