Sha256: f6f7c9b520eb3ba3d6404e52059c5fd98280d35d3d8d6b4dd942cf98c4f5f06c

Contents?: true

Size: 690 Bytes

Versions: 2

Compression:

Stored size: 690 Bytes

Contents

# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe String do

  describe "word_count" do
    it "should return 2" do
      "two words".word_count.should == 2
    end
    
    it "should handle hypenated words" do
      "one-way street".word_count.should == 2
    end
    
    it "should handle possessive apostrophe" do
      "this is max's ball".word_count.should == 4
    end
    
    context "when string is a different encoding" do
      it "should not blow up" do
        str = "two &#162words".force_encoding("ISO-8859-1")
        str.valid_encoding?.should == true
        str.word_count.should == 2
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
itrigga-core_ext-1.5.0 spec/string_spec.rb
itrigga-core_ext-1.3.0 spec/string_spec.rb