Sha256: 07645ec620fd6328a542b5ae70f9592b8bd1cef23b260a2a852da8a7afb79042

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'lib/usher'

Slash = Usher::Route::Separator::Slash
Dot = Usher::Route::Separator::Dot

describe "Usher route tokenizing" do
  
  
  it "should split / delimited routes" do
    Usher::Route::Splitter.new('/test/this/split').paths.first.should == [Slash, 'test', Slash, 'this', Slash, 'split']
  end
  
  it "should group optional parts with brackets" do
    Usher::Route::Splitter.new('/test/this(/split)').paths.should == [
      [Slash, 'test', Slash, 'this'],
      [Slash, 'test', Slash, 'this', Slash, 'split']
    ]
  end

  it "should group optional parts with brackets (for non overlapping groups)" do
    Usher::Route::Splitter.new('/test/this(/split)(/split2)').paths == [
      [Slash, "test", Slash, "this"],
      [Slash, "test", Slash, "this", Slash, "split"],
      [Slash, "test", Slash, "this", Slash, "split2"],
      [Slash, "test", Slash, "this", Slash, "split", Slash, "split2"]
    ]
  end

  it "should group nested-optional parts with brackets" do
    Usher::Route::Splitter.new('/test/this(/split(.:format))').paths == [
      [Slash, "test", Slash, "this"],
      [Slash, "test", Slash, "this", Slash, "split"],
      [Slash, "test", Slash, "this", Slash, "split", Dot, Usher::Route::Variable.new(:':', :format)]
    ]
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joshbuddy-usher-0.0.2 spec/split_spec.rb