Sha256: 3d72c50b2eae0754161491d80e3d0b481837e255e78a83c6bdd57166b549caa4
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
# encoding: utf-8 require 'spec_helper' describe TTY::Text::Distance, '#distance' do let(:object) { described_class.new(*strings) } subject(:distance) { object.distance } context 'when nil' do let(:strings) { [nil, nil] } it { is_expected.to eql(0) } end context 'when empty' do let(:strings) { ['', ''] } it { is_expected.to eql(0) } end context 'with one non empty' do let(:strings) { ['abc', ''] } it { is_expected.to eql(3) } end context 'when single char' do let(:strings) { ['a', 'abc'] } it { is_expected.to eql(2) } end context 'when similar' do let(:strings) { ['abc', 'abc'] } it { is_expected.to eql(0) } end context 'when similar' do let(:strings) { ['abc', 'acb'] } it { is_expected.to eql(1) } end context 'when end similar' do let(:strings) { ['saturday', 'sunday'] } it { is_expected.to eql(3) } end context 'when contain similar' do let(:strings) { ['which', 'witch'] } it { is_expected.to eql(2) } end context 'when prefix' do let(:strings) { ['sta', 'status'] } it { is_expected.to eql(3) } end context 'when similar' do let(:strings) { ['smellyfish','jellyfish'] } it { is_expected.to eql(2) } end context 'when unicode' do let(:strings) { ['マラソン五輪代表', 'ララソン五輪代表'] } it { is_expected.to eql(1) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tty-0.1.2 | spec/tty/text/distance/distance_spec.rb |
tty-0.1.1 | spec/tty/text/distance/distance_spec.rb |
tty-0.1.0 | spec/tty/text/distance/distance_spec.rb |