neography-calamitates 1.2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/.gitignore +15 -0
  2. data/.project +12 -0
  3. data/.travis.yml +4 -0
  4. data/CONTRIBUTORS +18 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +19 -0
  7. data/README.md +261 -0
  8. data/Rakefile +14 -0
  9. data/examples/facebook.rb +40 -0
  10. data/examples/facebook_v2.rb +25 -0
  11. data/examples/greatest.rb +43 -0
  12. data/examples/linkedin.rb +39 -0
  13. data/examples/linkedin_v2.rb +22 -0
  14. data/examples/traversal_example1.rb +65 -0
  15. data/examples/traversal_example2.rb +54 -0
  16. data/lib/neography.rb +45 -0
  17. data/lib/neography/config.rb +52 -0
  18. data/lib/neography/connection.rb +203 -0
  19. data/lib/neography/equal.rb +21 -0
  20. data/lib/neography/errors.rb +45 -0
  21. data/lib/neography/index.rb +52 -0
  22. data/lib/neography/multi_json_parser.rb +28 -0
  23. data/lib/neography/neography.rb +10 -0
  24. data/lib/neography/node.rb +53 -0
  25. data/lib/neography/node_path.rb +29 -0
  26. data/lib/neography/node_relationship.rb +37 -0
  27. data/lib/neography/node_traverser.rb +146 -0
  28. data/lib/neography/path_traverser.rb +100 -0
  29. data/lib/neography/property.rb +61 -0
  30. data/lib/neography/property_container.rb +29 -0
  31. data/lib/neography/railtie.rb +19 -0
  32. data/lib/neography/relationship.rb +70 -0
  33. data/lib/neography/relationship_traverser.rb +80 -0
  34. data/lib/neography/rest.rb +470 -0
  35. data/lib/neography/rest/auto_indexes.rb +64 -0
  36. data/lib/neography/rest/batch.rb +277 -0
  37. data/lib/neography/rest/clean.rb +19 -0
  38. data/lib/neography/rest/cypher.rb +33 -0
  39. data/lib/neography/rest/extensions.rb +25 -0
  40. data/lib/neography/rest/gremlin.rb +24 -0
  41. data/lib/neography/rest/helpers.rb +38 -0
  42. data/lib/neography/rest/indexes.rb +100 -0
  43. data/lib/neography/rest/node_auto_indexes.rb +14 -0
  44. data/lib/neography/rest/node_indexes.rb +50 -0
  45. data/lib/neography/rest/node_labels.rb +60 -0
  46. data/lib/neography/rest/node_paths.rb +57 -0
  47. data/lib/neography/rest/node_properties.rb +11 -0
  48. data/lib/neography/rest/node_relationships.rb +42 -0
  49. data/lib/neography/rest/node_traversal.rb +81 -0
  50. data/lib/neography/rest/nodes.rb +102 -0
  51. data/lib/neography/rest/other_node_relationships.rb +48 -0
  52. data/lib/neography/rest/paths.rb +36 -0
  53. data/lib/neography/rest/properties.rb +56 -0
  54. data/lib/neography/rest/relationship_auto_indexes.rb +14 -0
  55. data/lib/neography/rest/relationship_indexes.rb +35 -0
  56. data/lib/neography/rest/relationship_properties.rb +11 -0
  57. data/lib/neography/rest/relationship_types.rb +18 -0
  58. data/lib/neography/rest/relationships.rb +23 -0
  59. data/lib/neography/rest/schema_indexes.rb +34 -0
  60. data/lib/neography/rest/transactions.rb +102 -0
  61. data/lib/neography/tasks.rb +158 -0
  62. data/lib/neography/version.rb +3 -0
  63. data/neography.gemspec +32 -0
  64. data/spec/integration/authorization_spec.rb +48 -0
  65. data/spec/integration/index_spec.rb +70 -0
  66. data/spec/integration/neography_spec.rb +10 -0
  67. data/spec/integration/node_encoding_spec.rb +71 -0
  68. data/spec/integration/node_path_spec.rb +222 -0
  69. data/spec/integration/node_relationship_spec.rb +381 -0
  70. data/spec/integration/node_spec.rb +251 -0
  71. data/spec/integration/parsing_spec.rb +13 -0
  72. data/spec/integration/performance_spec.rb +17 -0
  73. data/spec/integration/relationship_spec.rb +37 -0
  74. data/spec/integration/rest_batch_spec.rb +512 -0
  75. data/spec/integration/rest_batch_streaming_spec.rb +32 -0
  76. data/spec/integration/rest_bulk_spec.rb +106 -0
  77. data/spec/integration/rest_experimental_spec.rb +22 -0
  78. data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
  79. data/spec/integration/rest_header_spec.rb +14 -0
  80. data/spec/integration/rest_index_spec.rb +468 -0
  81. data/spec/integration/rest_labels_spec.rb +128 -0
  82. data/spec/integration/rest_node_spec.rb +274 -0
  83. data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
  84. data/spec/integration/rest_path_spec.rb +231 -0
  85. data/spec/integration/rest_plugin_spec.rb +177 -0
  86. data/spec/integration/rest_relationship_spec.rb +354 -0
  87. data/spec/integration/rest_relationship_types_spec.rb +18 -0
  88. data/spec/integration/rest_schema_index_spec.rb +32 -0
  89. data/spec/integration/rest_transaction_spec.rb +166 -0
  90. data/spec/integration/rest_traverse_spec.rb +149 -0
  91. data/spec/matchers.rb +33 -0
  92. data/spec/neography_spec.rb +23 -0
  93. data/spec/spec_helper.rb +45 -0
  94. data/spec/unit/config_spec.rb +46 -0
  95. data/spec/unit/connection_spec.rb +211 -0
  96. data/spec/unit/node_spec.rb +100 -0
  97. data/spec/unit/properties_spec.rb +140 -0
  98. data/spec/unit/relationship_spec.rb +118 -0
  99. data/spec/unit/rest/batch_spec.rb +243 -0
  100. data/spec/unit/rest/clean_spec.rb +17 -0
  101. data/spec/unit/rest/cypher_spec.rb +21 -0
  102. data/spec/unit/rest/extensions_spec.rb +29 -0
  103. data/spec/unit/rest/gremlin_spec.rb +26 -0
  104. data/spec/unit/rest/labels_spec.rb +73 -0
  105. data/spec/unit/rest/node_auto_indexes_spec.rb +67 -0
  106. data/spec/unit/rest/node_indexes_spec.rb +141 -0
  107. data/spec/unit/rest/node_paths_spec.rb +80 -0
  108. data/spec/unit/rest/node_properties_spec.rb +80 -0
  109. data/spec/unit/rest/node_relationships_spec.rb +78 -0
  110. data/spec/unit/rest/node_traversal_spec.rb +128 -0
  111. data/spec/unit/rest/nodes_spec.rb +188 -0
  112. data/spec/unit/rest/paths_spec.rb +69 -0
  113. data/spec/unit/rest/relationship_auto_indexes_spec.rb +67 -0
  114. data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
  115. data/spec/unit/rest/relationship_properties_spec.rb +80 -0
  116. data/spec/unit/rest/relationship_types_spec.rb +16 -0
  117. data/spec/unit/rest/relationships_spec.rb +22 -0
  118. data/spec/unit/rest/schema_index_spec.rb +31 -0
  119. data/spec/unit/rest/transactions_spec.rb +44 -0
  120. metadata +372 -0
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ class Rest
5
+ describe NodeLabels do
6
+
7
+ let(:connection) { double }
8
+ subject { NodeLabels.new(connection) }
9
+
10
+ it "list node labels" do
11
+ connection.should_receive(:get).with("/labels")
12
+ subject.list
13
+ end
14
+
15
+ it "get labels for node" do
16
+ connection.should_receive(:get).with("/node/0/labels")
17
+ subject.get(0)
18
+ end
19
+
20
+ it "get nodes for labels" do
21
+ connection.should_receive(:get).with("/label/person/nodes")
22
+ subject.get_nodes("person")
23
+ end
24
+
25
+ it "find nodes for labels and property" do
26
+ connection.should_receive(:get).with("/label/person/nodes?name=%22max%22")
27
+ subject.find_nodes("person", {:name => "max"})
28
+ end
29
+
30
+ it "can add a label to a node" do
31
+ options = {
32
+ :body => '["Actor"]',
33
+ :headers => json_content_type
34
+ }
35
+ connection.should_receive(:post).with("/node/0/labels", options)
36
+ subject.add(0, ["Actor"])
37
+ end
38
+
39
+ it "can add labels to a node" do
40
+ options = {
41
+ :body => '["Actor","Director"]',
42
+ :headers => json_content_type
43
+ }
44
+ connection.should_receive(:post).with("/node/0/labels", options)
45
+ subject.add(0, ["Actor", "Director"])
46
+ end
47
+
48
+ it "can set a label to a node" do
49
+ options = {
50
+ :body => '["Actor"]',
51
+ :headers => json_content_type
52
+ }
53
+ connection.should_receive(:put).with("/node/0/labels", options)
54
+ subject.set(0, ["Actor"])
55
+ end
56
+
57
+ it "can add labels to a node" do
58
+ options = {
59
+ :body => '["Actor","Director"]',
60
+ :headers => json_content_type
61
+ }
62
+ connection.should_receive(:put).with("/node/0/labels", options)
63
+ subject.set(0, ["Actor", "Director"])
64
+ end
65
+
66
+ it "can delete a label from a node" do
67
+ connection.should_receive(:delete).with("/node/0/labels/Actor")
68
+ subject.delete(0,"Actor")
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ class Rest
5
+ describe NodeAutoIndexes do
6
+
7
+ let(:connection) { double }
8
+ subject { NodeAutoIndexes.new(connection) }
9
+
10
+ it "gets a node from an auto index" do
11
+ connection.should_receive(:get).with("/index/auto/node/some_key/some_value")
12
+ subject.get("some_key", "some_value")
13
+ end
14
+
15
+ it "returns nil if nothing was found in the auto index" do
16
+ connection.stub(:get).and_return(nil)
17
+ subject.get("some_key", "some_value").should be_nil
18
+ end
19
+
20
+ it "finds by key and value if value passed to #find_or_query" do
21
+ connection.should_receive(:get).with("/index/auto/node/some_key/some_value")
22
+ subject.find_or_query("some_key", "some_value")
23
+ end
24
+
25
+ it "finds by query if no value passed to #find_or_query" do
26
+ connection.should_receive(:get).with("/index/auto/node/?query=some_query")
27
+ subject.find_or_query("some_query")
28
+ end
29
+
30
+ it "finds by key and value" do
31
+ connection.should_receive(:get).with("/index/auto/node/some_key/some_value")
32
+ subject.find("some_key", "some_value")
33
+ end
34
+
35
+ it "finds by query" do
36
+ connection.should_receive(:get).with("/index/auto/node/?query=some_query")
37
+ subject.query("some_query")
38
+ end
39
+
40
+ it "gets the status" do
41
+ connection.should_receive(:get).with("/index/auto/node/status")
42
+ subject.status
43
+ end
44
+
45
+ it "sets the status" do
46
+ connection.should_receive(:put).with("/index/auto/node/status", hash_match(:body, '"foo"'))
47
+ subject.status = "foo"
48
+ end
49
+
50
+ it "gets auto index properties" do
51
+ connection.should_receive(:get).with("/index/auto/node/properties")
52
+ subject.properties
53
+ end
54
+
55
+ it "adds a property to an auto index" do
56
+ connection.should_receive(:post).with("/index/auto/node/properties", hash_match(:body, "foo"))
57
+ subject.add_property("foo")
58
+ end
59
+
60
+ it "removes a property from an auto index" do
61
+ connection.should_receive(:delete).with("/index/auto/node/properties/foo")
62
+ subject.remove_property("foo")
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ class Rest
5
+ describe NodeIndexes do
6
+
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
+ subject { NodeIndexes.new(connection) }
9
+
10
+ it "lists all indexes" do
11
+ connection.should_receive(:get).with("/index/node")
12
+ subject.list
13
+ end
14
+
15
+ it "creates a node index" do
16
+ expected_body = {
17
+ "config" => {
18
+ "type" => "some_type",
19
+ "provider" => "some_provider"
20
+ },
21
+ "name" => "some_index"
22
+ }
23
+ connection.should_receive(:post).with("/index/node", json_match(:body, expected_body))
24
+ subject.create("some_index", "some_type", "some_provider")
25
+ end
26
+
27
+ it "returns the post result after creation" do
28
+ connection.stub(:post).and_return("foo")
29
+ subject.create("some_index", "some_type", "some_provider").should == "foo"
30
+ end
31
+
32
+ it "creates an auto-index" do
33
+ expected_body = {
34
+ "config" => {
35
+ "type" => "some_type",
36
+ "provider" => "some_provider"
37
+ },
38
+ "name" => "node_auto_index"
39
+ }
40
+ connection.should_receive(:post).with("/index/node", json_match(:body, expected_body))
41
+ subject.create_auto("some_type", "some_provider")
42
+ end
43
+
44
+ it "creates a unique node in an index" do
45
+ expected_body = {
46
+ "properties" => "properties",
47
+ "key" => "key",
48
+ "value" => "value"
49
+ }
50
+ connection.should_receive(:post).with("/index/node/some_index?unique", json_match(:body, expected_body))
51
+ subject.create_unique("some_index", "key", "value", "properties")
52
+ end
53
+
54
+ it "gets or creates a unique node in an index" do
55
+ expected_body = {
56
+ "properties" => "properties",
57
+ "key" => "key",
58
+ "value" => "value"
59
+ }
60
+ connection.should_receive(:post).with("/index/node/some_index?uniqueness=get_or_create", json_match(:body, expected_body))
61
+ subject.get_or_create_unique("some_index", "key", "value", "properties")
62
+ end
63
+
64
+ it "adds a node to an index" do
65
+ expected_body = {
66
+ "uri" => "http://configuration/node/42",
67
+ "key" => "key",
68
+ "value" => "value"
69
+ }
70
+ connection.should_receive(:post).with("/index/node/some_index", json_match(:body, expected_body))
71
+ subject.add("some_index", "key", "value", "42")
72
+ end
73
+
74
+ it "gets a node from an index" do
75
+ connection.should_receive(:get).with("/index/node/some_index/some_key/some_value")
76
+ subject.get("some_index", "some_key", "some_value")
77
+ end
78
+
79
+ it "returns nil if nothing was found in the index" do
80
+ connection.stub(:get).and_return(nil)
81
+ subject.get("some_index", "some_key", "some_value").should be_nil
82
+ end
83
+
84
+ it "finds by key and value if both passed to #find" do
85
+ connection.should_receive(:get).with("/index/node/some_index/some_key/some_value")
86
+ subject.find("some_index", "some_key", "some_value")
87
+ end
88
+
89
+ it "finds by query if no value passed to #find" do
90
+ connection.should_receive(:get).with("/index/node/some_index?query=some_query")
91
+ subject.find("some_index", "some_query")
92
+ end
93
+
94
+ it "finds by key and value" do
95
+ connection.should_receive(:get).with("/index/node/some_index/some_key/some_value")
96
+ subject.find_by_key_value("some_index", "some_key", "some_value")
97
+ end
98
+
99
+ it "finds by query" do
100
+ connection.should_receive(:get).with("/index/node/some_index?query=some_query")
101
+ subject.find_by_query("some_index", "some_query")
102
+ end
103
+
104
+ it "removes a node from an index by id for #remove with two arguments" do
105
+ connection.should_receive(:delete).with("/index/node/some_index/42")
106
+ subject.remove("some_index", "42")
107
+ end
108
+
109
+ it "removes a node from an index by key for #remove with three arguments" do
110
+ connection.should_receive(:delete).with("/index/node/some_index/some_key/42")
111
+ subject.remove("some_index", "some_key", "42")
112
+ end
113
+
114
+ it "removes a node from an index by key and value for #remove with four arguments" do
115
+ connection.should_receive(:delete).with("/index/node/some_index/some_key/some_value/42")
116
+ subject.remove("some_index", "some_key", "some_value", "42")
117
+ end
118
+
119
+ it "removes a node from an index" do
120
+ connection.should_receive(:delete).with("/index/node/some_index/42")
121
+ subject.remove_by_id("some_index", "42")
122
+ end
123
+
124
+ it "removes a node from an index by key" do
125
+ connection.should_receive(:delete).with("/index/node/some_index/some_key/42")
126
+ subject.remove_by_key("some_index", "42", "some_key")
127
+ end
128
+
129
+ it "removes a node from an index by key and value" do
130
+ connection.should_receive(:delete).with("/index/node/some_index/some_key/some_value/42")
131
+ subject.remove_by_value("some_index", "42", "some_key", "some_value")
132
+ end
133
+
134
+ it "drops an index" do
135
+ connection.should_receive(:delete).with("/index/node/some_index")
136
+ subject.drop("some_index")
137
+ end
138
+
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ class Rest
5
+ describe NodePaths do
6
+
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
+ subject { NodePaths.new(connection) }
9
+
10
+ it "gets a shortest path between two nodes" do
11
+ expected_body = {
12
+ "to" => "http://configuration/node/43",
13
+ "relationships" => "relationships",
14
+ "max_depth" => 3,
15
+ "algorithm" => "shortestPath"
16
+ }
17
+
18
+ connection.should_receive(:post).with("/node/42/path", json_match(:body, expected_body))
19
+
20
+ subject.get("42", "43", "relationships", 3, "shortestPath")
21
+ end
22
+
23
+ it "gets all shortest paths between two nodes" do
24
+ expected_body = {
25
+ "to" => "http://configuration/node/43",
26
+ "relationships" => "relationships",
27
+ "max_depth" => 3,
28
+ "algorithm" => "shortestPath"
29
+ }
30
+
31
+ connection.should_receive(:post).with("/node/42/paths", json_match(:body, expected_body))
32
+
33
+ subject.get_all("42", "43", "relationships", 3, "shortestPath")
34
+ end
35
+
36
+ it "gets all shortest weighted paths between two nodes" do
37
+ expected_body = {
38
+ "to" => "http://configuration/node/43",
39
+ "relationships" => "relationships",
40
+ "cost_property" => "cost",
41
+ "max_depth" => 3,
42
+ "algorithm" => "shortestPath"
43
+ }
44
+
45
+ connection.should_receive(:post).with("/node/42/paths", json_match(:body, expected_body))
46
+
47
+ subject.shortest_weighted("42", "43", "relationships", "cost", 3, "shortestPath")
48
+ end
49
+
50
+ context "algorithm" do
51
+
52
+ subject { NodePaths.new(nil) }
53
+
54
+ [ :shortest, "shortest", :shortestPath, "shortestPath", :short, "short" ].each do |algorithm|
55
+ it "parses shortestPath" do
56
+ subject.send(:get_algorithm, algorithm).should == "shortestPath"
57
+ end
58
+ end
59
+
60
+ [ :allSimplePaths, "allSimplePaths", :simple, "simple" ].each do |algorithm|
61
+ it "parses allSimplePaths" do
62
+ subject.send(:get_algorithm, algorithm).should == "allSimplePaths"
63
+ end
64
+ end
65
+
66
+ [ :dijkstra, "dijkstra" ].each do |algorithm|
67
+ it "parses dijkstra" do
68
+ subject.send(:get_algorithm, algorithm).should == "dijkstra"
69
+ end
70
+ end
71
+
72
+ it "parses allPaths by default" do
73
+ subject.send(:get_algorithm, "foo").should == "allPaths"
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ class Rest
5
+ describe NodeProperties do
6
+
7
+ let(:connection) { double }
8
+ subject { NodeProperties.new(connection) }
9
+
10
+ it "sets properties" do
11
+ options1 = {
12
+ :body => '"bar"',
13
+ :headers => json_content_type
14
+ }
15
+ options2 = {
16
+ :body => '"qux"',
17
+ :headers => json_content_type
18
+ }
19
+ connection.should_receive(:put).with("/node/42/properties/foo", options1)
20
+ connection.should_receive(:put).with("/node/42/properties/baz", options2)
21
+ subject.set("42", {:foo => "bar", :baz => "qux"})
22
+ end
23
+
24
+ it "resets properties" do
25
+ options = {
26
+ :body => '{"foo":"bar"}',
27
+ :headers => json_content_type
28
+ }
29
+ connection.should_receive(:put).with("/node/42/properties", options)
30
+ subject.reset("42", {:foo => "bar"})
31
+ end
32
+
33
+ context "getting properties" do
34
+
35
+ it "gets all properties" do
36
+ connection.should_receive(:get).with("/node/42/properties")
37
+ subject.get("42")
38
+ end
39
+
40
+ it "gets multiple properties" do
41
+ connection.should_receive(:get).with("/node/42/properties/foo")
42
+ connection.should_receive(:get).with("/node/42/properties/bar")
43
+ subject.get("42", "foo", "bar")
44
+ end
45
+
46
+ it "returns multiple properties as a hash" do
47
+ connection.stub(:get).and_return("baz", "qux")
48
+ subject.get("42", "foo", "bar").should == { "foo" => "baz", "bar" => "qux" }
49
+ end
50
+
51
+ it "returns nil if no properties were found" do
52
+ connection.stub(:get).and_return(nil, nil)
53
+ subject.get("42", "foo", "bar").should be_nil
54
+ end
55
+
56
+ it "returns hash without nil return values" do
57
+ connection.stub(:get).and_return("baz", nil)
58
+ subject.get("42", "foo", "bar").should == { "foo" => "baz" }
59
+ end
60
+
61
+ end
62
+
63
+ context "removing properties" do
64
+
65
+ it "removes all properties" do
66
+ connection.should_receive(:delete).with("/node/42/properties")
67
+ subject.remove("42")
68
+ end
69
+
70
+ it "removes multiple properties" do
71
+ connection.should_receive(:delete).with("/node/42/properties/foo")
72
+ connection.should_receive(:delete).with("/node/42/properties/bar")
73
+ subject.remove("42", "foo", "bar")
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ class Rest
5
+ describe NodeRelationships do
6
+
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
+ subject { NodeRelationships.new(connection) }
9
+
10
+ it "creates a relationship" do
11
+ body_hash = { "type" => "some_type",
12
+ "to" => "http://configuration/node/43",
13
+ "data" => {"foo"=>"bar","baz"=>"qux"}
14
+ }
15
+ connection.should_receive(:post).with("/node/42/relationships", json_match(:body, body_hash))
16
+
17
+ subject.create("some_type", "42", "43", {:foo => "bar", :baz => "qux"})
18
+ end
19
+
20
+ it "returns the post results" do
21
+ connection.stub(:post).and_return("foo")
22
+
23
+ subject.create("some_type", "42", "43", {}).should == "foo"
24
+ end
25
+
26
+ it "gets relationships" do
27
+ connection.should_receive(:get).with("/node/42/relationships/all")
28
+ subject.get("42")
29
+ end
30
+
31
+ it "gets relationships with direction" do
32
+ connection.should_receive(:get).with("/node/42/relationships/in")
33
+ subject.get("42", :in)
34
+ end
35
+
36
+ it "gets relationships with direction and type" do
37
+ connection.should_receive(:get).with("/node/42/relationships/in/foo")
38
+ subject.get("42", :in, "foo")
39
+ end
40
+
41
+ it "gets relationships with direction and types" do
42
+ connection.should_receive(:get).with("/node/42/relationships/in/foo%26bar")
43
+ subject.get("42", :in, ["foo", "bar"])
44
+ end
45
+
46
+ it "returns nil if no relationships were found" do
47
+ connection.stub(:get).and_return(nil)
48
+ subject.get("42", :in).should be_nil
49
+ end
50
+
51
+ it "returns nil if no relationships were found by type" do
52
+ connection.stub(:get).and_return(nil)
53
+ subject.get("42", :in, "foo")
54
+ end
55
+
56
+ context "directions" do
57
+
58
+ [ :incoming, "incoming", :in, "in" ].each do |direction|
59
+ it "parses 'in' direction" do
60
+ NodeRelationships.new(nil).parse_direction(direction).should == "in"
61
+ end
62
+ end
63
+
64
+ [ :outgoing, "outgoing", :out, "out" ].each do |direction|
65
+ it "parses 'out' direction" do
66
+ NodeRelationships.new(nil).parse_direction(direction).should == "out"
67
+ end
68
+ end
69
+
70
+ it "parses 'all' direction by default" do
71
+ NodeRelationships.new(nil).parse_direction("foo").should == "all"
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end
78
+ end