Skip to content

Commit

Permalink
Add traversal options spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdvdijk committed Sep 8, 2012
1 parent 0160de5 commit 26f9e0e
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions spec/unit/rest/node_traversal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,98 @@ class Rest
subject.traverse("42", :relationship, description)
end

context "options" do
let(:traversal) { NodeTraversal.new(nil) }

context "order" do
[ :breadth, "breadth", "breadth first", "breadthFirst", :wide, "wide" ].each do |order|
it "parses breadth first" do
subject.send(:get_order, order).should == "breadth first"
end
end

it "parses depth first by default" do
subject.send(:get_order, "foo").should == "depth first"
end
end

context "uniqueness" do
[ :nodeglobal, "node global", "nodeglobal", "node_global" ].each do |order|
it "parses node global" do
subject.send(:get_uniqueness, order).should == "node global"
end
end

[ :nodepath, "node path", "nodepath", "node_path" ].each do |order|
it "parses node path" do
subject.send(:get_uniqueness, order).should == "node path"
end
end

[ :noderecent, "node recent", "noderecent", "node_recent" ].each do |order|
it "parses node recent" do
subject.send(:get_uniqueness, order).should == "node recent"
end
end

[ :relationshipglobal, "relationship global", "relationshipglobal", "relationship_global" ].each do |order|
it "parses relationship global" do
subject.send(:get_uniqueness, order).should == "relationship global"
end
end

[ :relationshippath, "relationship path", "relationshippath", "relationship_path" ].each do |order|
it "parses relationship path" do
subject.send(:get_uniqueness, order).should == "relationship path"
end
end

[ :relationshiprecent, "relationship recent", "relationshiprecent", "relationship_recent" ].each do |order|
it "parses relationship recent" do
subject.send(:get_uniqueness, order).should == "relationship recent"
end
end

it "parses none by default" do
subject.send(:get_uniqueness, "foo").should == "none"
end
end

context "depth" do
it "parses nil as nil" do
subject.send(:get_depth, nil).should be_nil
end
it "parses 0 as 1" do
subject.send(:get_depth, "0").should == 1
end
it "parses integers" do
subject.send(:get_depth, "42").should == 42
end
end

context "type" do
[ :relationship, "relationship", :relationships, "relationships" ].each do |type|
it "parses relationship" do
subject.send(:get_type, type).should == "relationship"
end
end
[ :path, "path", :paths, "paths" ].each do |type|
it "parses path" do
subject.send(:get_type, type).should == "path"
end
end
[ :fullpath, "fullpath", :fullpaths, "fullpaths" ].each do |type|
it "parses fullpath" do
subject.send(:get_type, type).should == "fullpath"
end
end

it "parses node by default" do
subject.send(:get_type, "foo").should == "node"
end
end
end

end
end
end

0 comments on commit 26f9e0e

Please sign in to comment.