Sha256: 9fd960d8d1148efa8c8e0ea275c66c492c49ba499dc40673d2c2acd63e8e032d

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])

describe String do
  context "tokenize" do
    it 'should split words' do
      "hello world".tokenize.should == %w[hello world]
    end

    it 'should downcase words' do
      "Hello World".tokenize.should == %w[hello world]
    end

    it 'should strip special characters' do
      "blah, bla!".tokenize.should == %w[blah bla]
    end

    it 'should prserve infix hyphens and underscores' do
      "hyphen-ated under_score".tokenize.should == %w[hyphen-ated under_score]
    end

    it 'should sanitize html tags' do
      '<a href="http://example.org">example</a>'.tokenize.should == %w[example]
    end

    it 'should preserve infix periods' do
      'example.org rocks. read it...'.tokenize.should == %w[example.org rocks read it]
    end
    
    it "should preserve infix commas" do
      '$1,000,000.00 or $1.000.000,00'.tokenize.should == %w[1,000,000.00 or 1.000.000,00]
    end
    
    it "should strip quotes around tokens" do
      '"first last"'.tokenize.should == %w[first last]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
groupie-0.3.0 spec/groupie/core_ext/string_spec.rb
groupie-0.2.2 spec/groupie/core_ext/string_spec.rb
groupie-0.1.1 spec/groupie/core_ext/string_spec.rb