Sha256: de5cdf82436ec8364c7bb493786afdb948a8b0b93f5aa2e45b6d4cbe676531d2

Contents?: true

Size: 922 Bytes

Versions: 107

Compression:

Stored size: 922 Bytes

Contents

require 'spec_helper'

describe Picky::API::Tokenizer do
  let(:object) do
    Class.new do
      include Picky::API::Tokenizer::CharacterSubstituter
    end.new
  end
  context 'extract_character_substituter' do
    context 'with a substituter' do
      let(:substituter) do
        Class.new do
          def substitute text
            text.tr('a-z', '1-9')
          end
        end.new
      end
      it 'creates a tokenizer' do
        object.extract_character_substituter(substituter).
          substitute("picky").should == '99399'
      end
    end
    context 'invalid tokenizer' do
      it 'raises with a nice error message' do
        expect {
          object.extract_character_substituter Object.new
        }.to raise_error(<<-ERROR)
The substitutes_characters_with option needs a character substituter,
which responds to #substitute(text) and returns substituted_text."
ERROR
      end
    end
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
picky-4.5.5 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.5.4 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.5.3 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.5.2 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.5.1 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.5.0 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.4.2 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.4.1 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.4.0 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.3.2 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.3.1 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.3.0 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.2.4 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.2.3 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.2.2 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.2.1 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.2.0 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.1.0 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.0.9 spec/lib/api/tokenizer/character_substituter_spec.rb
picky-4.0.8 spec/lib/api/tokenizer/character_substituter_spec.rb