Sha256: ca3d789f7872a675d40cfbcf4dc799ed8b4cf5606948fb568e91b596d2c07b20

Contents?: true

Size: 832 Bytes

Versions: 28

Compression:

Stored size: 832 Bytes

Contents

require File.expand_path('spec/spec_helper')

describe String do
  describe :naive_split do
    it "splits repeated pattern" do
      "aaa".naive_split('a').should == ['','','','']
    end

    it "splits normal stuff" do
      "abacad".naive_split('a').should == ['','b','c','d']
    end

    it "splits empty into 1" do
      "".naive_split('a').should == ['']
    end

    it "splits 1 into 2" do
      "a".naive_split('a').should == ['','']
    end
  end

  describe :surrounded_in? do
    [
      ['aba','a',true],
      ['abcab','ab',true],
      ['acc','a',false],
      ['cca','a',false],
      ['(cca)',['(',')'],true],
      ['(cca',['(',')'],false],
    ].each do |text, word, success|
      it "is #{success} for #{word} in #{text}" do
        text.surrounded_in?(*[*word]).should == success
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ruco-0.2.12 spec/ruco/core_ext/string_spec.rb
ruco-0.2.11 spec/ruco/core_ext/string_spec.rb
ruco-0.2.10 spec/ruco/core_ext/string_spec.rb
ruco-0.2.9 spec/ruco/core_ext/string_spec.rb
ruco-0.2.8 spec/ruco/core_ext/string_spec.rb
ruco-0.2.7 spec/ruco/core_ext/string_spec.rb
ruco-0.2.6 spec/ruco/core_ext/string_spec.rb
ruco-0.2.5 spec/ruco/core_ext/string_spec.rb
ruco-0.2.4 spec/ruco/core_ext/string_spec.rb
ruco-0.2.3 spec/ruco/core_ext/string_spec.rb
ruco-0.2.2 spec/ruco/core_ext/string_spec.rb
ruco-0.2.1 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta12 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta11 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta10 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta9 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta8 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta7 spec/ruco/core_ext/string_spec.rb
ruco-0.2.0.beta6 spec/ruco/core_ext/string_spec.rb