spec/split_spec.rb in joshbuddy-usher-0.3.0 vs spec/split_spec.rb in joshbuddy-usher-0.3.2
- old
+ new
@@ -2,56 +2,56 @@
describe "Usher route tokenizing" do
it "should split / delimited routes" do
- Usher::Splitter.delimiter('/').split('/test/this/split').should == [['test', 'this', 'split']]
+ Usher::Splitter.for_delimiters(['/', '.']).split('/test/this/split').should == [[:/, 'test', :/,'this', :/, 'split']]
end
it "should split on ' ' delimited routes as well" do
- Usher::Splitter.delimiter(' ').split('test this split').should == [['test', 'this', 'split']]
+ Usher::Splitter.for_delimiters([' ']).split('test this split').should == [['test', :' ', 'this', :' ', 'split']]
end
it "should split on ' ' delimited routes for more complex routes as well" do
- Usher::Splitter.delimiter(' ').split('(test|this) split').should == [['test', 'split'], ['this', 'split']]
+ Usher::Splitter.for_delimiters([' ']).split('(test|this) split').should == [['test', :' ', 'split'], ['this', :' ', 'split']]
end
it "should group optional parts with brackets" do
- Usher::Splitter.delimiter('/').split('/test/this(/split)').should == [
- ['test', 'this'],
- ['test', 'this', 'split']
+ Usher::Splitter.for_delimiters(['/', '.']).split('/test/this(/split)').should == [
+ [:/, 'test', :/, 'this'],
+ [:/, 'test', :/, 'this', :/, 'split']
]
end
it "should group exclusive optional parts with brackets and pipes" do
- Usher::Splitter.delimiter('/').split('/test/this(/split|/split2)').should == [
- ['test', 'this', 'split'],
- ['test', 'this', 'split2']
+ Usher::Splitter.for_delimiters(['/', '.']).split('/test/this(/split|/split2)').should == [
+ [:/, 'test', :/, 'this',:/, 'split'],
+ [:/, 'test', :/, 'this',:/, 'split2']
]
end
it "should group exclusive optional-optional parts with brackets and pipes" do
- Usher::Splitter.delimiter('/').split('/test/this((/split|/split2))').should == [
- ['test', 'this'],
- ['test', 'this', 'split'],
- ['test', 'this', 'split2']
+ Usher::Splitter.for_delimiters(['/', '.']).split('/test/this((/split|/split2))').should == [
+ [:/, 'test',:/, 'this'],
+ [:/, 'test',:/, 'this', :/, 'split'],
+ [:/, 'test',:/, 'this', :/, 'split2']
]
end
it "should group optional parts with brackets (for non overlapping groups)" do
- Usher::Splitter.delimiter('/').split('/test/this(/split)(/split2)') == [
- ["test", "this"],
- ["test", "this", "split"],
- ["test", "this", "split2"],
- ["test", "this", "split", "split2"]
+ Usher::Splitter.for_delimiters(['/', '.']).split('/test/this(/split)(/split2)') == [
+ [:/, "test", :/, "this"],
+ [:/, "test", :/, "this", :/, "split"],
+ [:/, "test", :/, "this", :/, "split2"],
+ [:/, "test", :/, "this", :/, "split", :/, "split2"]
]
end
it "should group nested-optional parts with brackets" do
- Usher::Splitter.delimiter('/').split('/test/this(/split(.:format))') == [
- ["test", "this"],
- ["test", "this", "split"],
- ["test", "this", "split", Usher::Route::Variable.new(:'.:', :format)]
+ Usher::Splitter.for_delimiters(['/', '.']).split('/test/this(/split(.:format))') == [
+ [:/, "test", :/, "this"],
+ [:/, "test", :/, "this", :/, "split"],
+ [:/, "test", :/, "this", :/, "split", '.', Usher::Route::Variable.new(:':', :format)]
]
end
end
\ No newline at end of file