Sha256: 03371ab29e759bdd8aa60231f51fd8192719d8f2da5d3f0d7e264ce857b27cec

Contents?: true

Size: 809 Bytes

Versions: 6

Compression:

Stored size: 809 Bytes

Contents

require "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

6 entries across 6 versions & 1 rubygems

Version Path
ruco-0.2.18 spec/ruco/core_ext/string_spec.rb
ruco-0.2.17 spec/ruco/core_ext/string_spec.rb
ruco-0.2.16 spec/ruco/core_ext/string_spec.rb
ruco-0.2.15 spec/ruco/core_ext/string_spec.rb
ruco-0.2.14 spec/ruco/core_ext/string_spec.rb
ruco-0.2.13 spec/ruco/core_ext/string_spec.rb