Sha256: bb4bc79b5f893b9694011bda3582f9709feca051dce20675c9669954c51f53ed

Contents?: true

Size: 1.51 KB

Versions: 18

Compression:

Stored size: 1.51 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
require "usher"

describe Usher::Splitter, "#split" do
  describe "when there are single-character delimiters" do
    it "should split correctly" do
      Usher::Splitter.for_delimiters(['.', '/']).split('/one/two.three/').should == ['/', 'one', '/', 'two', '.', 'three', '/']
    end
  end

  describe "when there are multi-character delimiters" do
    it "should split correctly" do
      Usher::Splitter.for_delimiters(['/', '%28', '%29']).split('/one%28two%29three/').should == ['/', 'one', '%28', 'two', '%29', 'three', '/']
    end
  end

  describe "when there is no delimiter in the end" do
    it "should split correctly" do
      Usher::Splitter.for_delimiters(['.', '/']).split('/one/two.three').should == ['/', 'one', '/', 'two', '.', 'three']
    end
  end

  describe "when there is no delimiter in the beginning" do
    it "should split correctly" do
      Usher::Splitter.for_delimiters(['.', '/']).split('one/two.three/').should == ['one', '/', 'two', '.', 'three', '/']
    end
  end

  describe "when delimiters are consecutive" do
    it "should split correctly" do
      Usher::Splitter.for_delimiters(['/', '!']).split('/cheese/!parmesan').should == ['/', 'cheese', '/', '!', 'parmesan']
    end
  end

  describe "when delimiters contain escaped characters" do
    it "should split correctly" do
      Usher::Splitter.for_delimiters(['/', '\(', '\)']).split('/cheese(parmesan)').should == ['/', 'cheese', '(', 'parmesan', ')']
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
usher-0.7.5 spec/private/splitter_spec.rb
usher-0.7.4 spec/private/splitter_spec.rb
usher-0.7.3 spec/private/splitter_spec.rb
usher-0.7.2 spec/private/splitter_spec.rb
usher-0.7.1 spec/private/splitter_spec.rb
usher-0.7.0 spec/private/splitter_spec.rb
usher-0.6.8 spec/private/splitter_spec.rb
usher-0.6.7 spec/private/splitter_spec.rb
usher-0.6.6 spec/private/splitter_spec.rb
usher-0.6.5 spec/private/splitter_spec.rb
usher-0.6.4 spec/private/splitter_spec.rb
usher-0.6.3 spec/private/splitter_spec.rb
usher-0.6.2 spec/private/splitter_spec.rb
usher-0.6.1 spec/private/splitter_spec.rb
usher-0.6.0 spec/private/splitter_spec.rb
usher-0.5.13 spec/private/splitter_spec.rb
usher-0.5.12 spec/private/splitter_spec.rb
usher-0.5.11 spec/private/splitter_spec.rb