Sha256: de8a7190b67ff6e4802bae8717b1c90b74a19bf3c2181f547de43622ac7d8356

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

require 'spec_helper'

module BerkeleyLibrary
  module Util
    describe Strings do
      describe :diff_index do
        it 'returns nil for identical strings' do
          s = 'elvis'
          expect(Strings.diff_index(s, s)).to be_nil
        end

        it 'returns the index for different strings' do
          s1 = 'elvis aaron presley'
          s2 = 'elvis nikita presley'
          expect(Strings.diff_index(s1, s2)).to eq(6)
        end

        it 'returns the length of the shorter string for prefixes' do
          s1 = 'elvis'
          s2 = 'elvis aaron presley'
          expect(Strings.diff_index(s1, s2)).to eq(5)
          expect(Strings.diff_index(s2, s1)).to eq(5)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
berkeley_library-tind-0.4.1 spec/berkeley_library/util/strings_spec.rb
berkeley_library-tind-0.4.0 spec/berkeley_library/util/strings_spec.rb