Sha256: 7d8018ac92156e99495e5540935d355b22f30b9ecf5daceb282387d1bb2917b0

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 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.new(['.', '/']).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.new(['/', '%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.new(['.', '/']).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.new(['.', '/']).split('one/two.three/').should == ['one', '/', 'two', '.', 'three', '/']
    end
  end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
usher-0.8.3 spec/private/splitter_spec.rb
usher-0.8.2 spec/private/splitter_spec.rb
usher-0.8.1 spec/private/splitter_spec.rb
usher-0.8.0 spec/private/splitter_spec.rb