spec/path_spec.rb in joshbuddy-usher-0.3.2 vs spec/path_spec.rb in joshbuddy-usher-0.3.3
- old
+ new
@@ -34,6 +34,35 @@
it "should allow named routes to be added" do
route_set.add_named_route(:route, '/bad/route', :controller => 'sample').should == route_set.named_routes[:route]
end
+ it "should calculate depths for nodes" do
+ route_set.add_named_route(:route, '/bad/route/three/four')
+ route_set.tree.depth.should == 0
+ route_set.tree.lookup[:/].depth.should == 1
+ end
+
+ it "should pp for nodes" do
+ route_set.add_named_route(:route, '/bad/route/three/four')
+ route_set.tree.depth.should == 0
+ old_out = $stdout
+ $stdout = (output = StringIO.new)
+ route_set.tree.lookup[:/].lookup['bad'].lookup[:/].pp
+ $stdout = old_out
+ output.rewind
+ output.read.should == <<-HEREDOC
+ 3: :/ false
+ route ==>
+ 4: "route" false
+ / ==>
+ 5: :/ false
+ three ==>
+ 6: "three" false
+ / ==>
+ 7: :/ false
+ four ==>
+ 8: "four" true
+ HEREDOC
+ end
+
end
\ No newline at end of file