Sha256: 6e743e970049747533300e9e7785badef80b00103e3237f864fbac282dda31a8
Contents?: true
Size: 900 Bytes
Versions: 3
Compression:
Stored size: 900 Bytes
Contents
require 'vindsl/prefix_matcher' describe Vindsl::PrefixMatcher do let(:data){ {'a'=>'a', 'ba' => 'ba', 'bb' => 'bb'} } subject{ described_class.new data } it 'matches a one-character string' do expect(subject.find 'a').to eq 'a' end it 'matches a max-character string' do expect(subject.find 'ba').to eq 'ba' end it 'returns nil on a failed match' do expect(subject.find 'c').to be_nil end describe 'all_prefixes' do it 'calculates all prefixes for a string' do expect(subject.all_prefixes 'abc').to eq %w{a ab abc} end end describe 'first_prefix' do it 'returns the first prefix that matches a hash entry' do expect(subject.first_prefix 'abc').to eq 'a' expect(subject.first_prefix 'ba').to eq 'ba' end it 'returns nil on a non-matching prefix' do expect(subject.first_prefix 'ccc').to be_nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vindsl-0.0.3 | spec/prefix_matcher_spec.rb |
vindsl-0.0.2 | spec/prefix_matcher_spec.rb |
vindsl-0.0.1 | spec/prefix_matcher_spec.rb |