From 0160de58090970fd8abbd0ebf5a2f2b01db7b860 Mon Sep 17 00:00:00 2001 From: Roel van Dijk Date: Sat, 8 Sep 2012 21:26:55 +0200 Subject: [PATCH] Add traversal spec. --- spec/matchers.rb | 1 - spec/unit/rest/node_traversal_spec.rb | 36 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 spec/unit/rest/node_traversal_spec.rb diff --git a/spec/matchers.rb b/spec/matchers.rb index 955a23a..27d9695 100644 --- a/spec/matchers.rb +++ b/spec/matchers.rb @@ -2,7 +2,6 @@ RSpec::Matchers.define :json_match do |field, expected| match do |actual| - p actual[field] expected == JSON.parse(actual[field]) end diff --git a/spec/unit/rest/node_traversal_spec.rb b/spec/unit/rest/node_traversal_spec.rb new file mode 100644 index 0000000..0d339c2 --- /dev/null +++ b/spec/unit/rest/node_traversal_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +module Neography + class Rest + describe NodeTraversal do + + let(:connection) { stub } + subject { NodeTraversal.new(connection) } + + it "traverses" do + description = { + "order" => :breadth, + "uniqueness" => :nodeglobal, + "relationships" => "relationships", + "prune evaluator" => "prune_evaluator", + "return filter" => "return_filter", + "depth" => 4 + } + + expected_body = { + "order" => "breadth first", + "uniqueness" => "node global", + "relationships" => "relationships", + "prune_evaluator" => "prune_evaluator", + "return_filter" => "return_filter", + "max_depth" => 4 + } + + connection.should_receive(:post).with("/node/42/traverse/relationship", json_match(:body, expected_body)) + + subject.traverse("42", :relationship, description) + end + + end + end +end