spec/scientific_name_spec.rb in name-spotter-0.2.4 vs spec/scientific_name_spec.rb in name-spotter-0.3.0

- old
+ new

@@ -1,25 +1,20 @@ -# encoding: utf-8 -require File.expand_path(File.dirname(__FILE__) + '/spec_helper') - describe NameSpotter::ScientificName do - - describe "without doing anything" do - before :each do - @find_me = "M. musculus" - @name = NameSpotter::ScientificName.new(@find_me, {:start_position => 30, :scientific_name => "Mus musculus"}) + + describe ".new" do + it "calculates end_pos" do + find_me = "M. musculus" + name = NameSpotter::ScientificName.new( + find_me, { start_position: 30, scientific_name: "Mus musculus" } + ) + expect(name.end_pos).to eq(name.start_pos + find_me.length - 1) end - - it "should have figured out the end position" do - @name.end_pos.should eq @name.start_pos + @find_me.length - 1 - end - end - - describe "unicode" do - it "should handle unicode characters" do + + it "handles unicode characters" do verbatim = "Slovenščina" - name = NameSpotter::ScientificName.new(verbatim, {:start_position => 48193}) - name.verbatim.should eq verbatim - name.end_pos.should eq name.start_pos + verbatim.length - 1 + name = NameSpotter::ScientificName. + new(verbatim, { start_position: 48193 }) + expect(name.verbatim).to eq verbatim + expect(name.end_pos).to eq(name.start_pos + verbatim.length - 1) end end end