Sha256: 6f12369b329a3aa0d266f60492b45f834ad5c419b60961b502c8e7236bdd0b6a

Contents?: true

Size: 990 Bytes

Versions: 4

Compression:

Stored size: 990 Bytes

Contents

require 'lib/usher'

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
joshbuddy-usher-0.0.3 spec/split_spec.rb
joshbuddy-usher-0.1.0 spec/split_spec.rb
joshbuddy-usher-0.1.1 spec/split_spec.rb
joshbuddy-usher-0.1.2 spec/split_spec.rb